Skip to content

Commit

Permalink
Merge branch 'release/0.1.14'
Browse files Browse the repository at this point in the history
  • Loading branch information
lb803 committed Mar 27, 2023
2 parents 54e62f3 + cf03fef commit b996867
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
2 changes: 1 addition & 1 deletion __init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

class AccessAidePlugin(EditBookToolPlugin):
name = 'Access Aide'
version = (0, 1, 12)
version = (0, 1, 14)
author = 'Luca Baffa'
supported_platforms = ['windows', 'osx', 'linux']
description = 'Enhance accessibility features in EPUB files.'
Expand Down
22 changes: 21 additions & 1 deletion main.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,9 @@ def main(self):
self.add_aria(container.parsed(name))

elif media_type in OPF_MIME:
self.add_lang_opf(container.parsed(name),
self.get_lang(container))
self.add_metadata(container)

self.add_a11y(container)

else:
Expand Down Expand Up @@ -154,6 +155,25 @@ def add_lang(self, root, lang):
self.write_attrib(html, '{http://www.w3.org/XML/1998/namespace}lang',
lang, self.lang_stat)

def add_lang_opf(self, root, lang):
'''Add language attributes to <package> tag in the `content.opf` file.
This method finds the <package> tag of the given 'root' element
and adds a 'xml:lang' language declarations. Changes are tracked and
successes increase a stat counter.
Note: the 'xml:lang' attribute of the <package> note is set to the
book language value defined in the OPF file (<dc:language>).
This would not be appropriate in the case where the book is written
in a language different from the one used in the `content.opf` file.
'''

pkg = root.xpath('//*[local-name()="package"]')[0]

# set lang for 'xml:lang' attribute
self.write_attrib(pkg, '{http://www.w3.org/XML/1998/namespace}lang',
lang, self.lang_stat)

def add_aria(self, root):
'''Add aria roles.
Expand Down

0 comments on commit b996867

Please sign in to comment.