Skip to content

Commit

Permalink
more substitutions and final curly brace stripping (#49)
Browse files Browse the repository at this point in the history
  • Loading branch information
LazyScholar authored Jul 9, 2021
1 parent 19bd40e commit a5513b0
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 18 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "DocumenterCitations"
uuid = "daee34ce-89f3-4625-b898-19384cb65244"
version = "0.2.8"
version = "0.2.9"

[deps]
Bibliography = "f1be7e48-bf82-45af-a471-ae754a193061"
Expand Down
33 changes: 17 additions & 16 deletions src/bibliography.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,30 +6,31 @@ Selectors.matcher(::Type{BibliographyBlock}, node, page, doc) = Expanders.iscode
const tex2unicode_replacements = (
"---" => "", # em dash needs to go first
"--" => "",
r"\\`\{(\S)\}" => s"\1\u300", # \`{o} ò grave accent
r"\\'\{(\S)\}" => s"\1\u301", # \'{o} ó acute accent
r"\\\^\{(\S)\}" => s"\1\u302", # \^{o} ô circumflex
r"\\~\{(\S)\}" => s"\1\u303", # \~{o} õ tilde
r"\\=\{(\S)\}" => s"\1\u304", # \={o} ō macron accent (a bar over the letter)
r"\\u\{(\S)\}" => s"\1\u306", # \u{o} ŏ breve over the letter
r"\\\.\{(\S)\}" => s"\1\u307", # \.{o} ȯ dot over the letter
r"\\\\\"\{(\S)\}" => s"\1\u308", # \"{o} ö umlaut, trema or dieresis
r"\\r\{(\S)\}" => s"\1\u30A", # \r{a} å ring over the letter (for å there is also the special command \aa)
r"\\H\{(\S)\}" => s"\1\u30B", # \H{o} ő long Hungarian umlaut (double acute)
r"\\v\{(\S)\}" => s"\1\u30C", # \v{s} š caron/háček ("v") over the letter
r"\\d\{(\S)\}" => s"\1\u323", # \d{u} ụ dot under the letter
r"\\c\{(\S)\}" => s"\1\u327", # \c{c} ç cedilla
r"\\k\{(\S)\}" => s"\1\u328", # \k{a} ą ogonek
r"\\b\{(\S)\}" => s"\1\u331", # \b{b} ḇ bar under the letter
r"\\`\{(\S{1})\}" => s"\1\u300", # \`{o} ò grave accent
r"\\'\{(\S{1})\}" => s"\1\u301", # \'{o} ó acute accent
r"\\\^\{(\S{1})\}" => s"\1\u302", # \^{o} ô circumflex
r"\\~\{(\S{1})\}" => s"\1\u303", # \~{o} õ tilde
r"\\=\{(\S{1})\}" => s"\1\u304", # \={o} ō macron accent (a bar over the letter)
r"\\u\{(\S{1})\}" => s"\1\u306", # \u{o} ŏ breve over the letter
r"\\\.\{(\S{1})\}" => s"\1\u307", # \.{o} ȯ dot over the letter
r"\\\\\"\{(\S{1})\}" => s"\1\u308", # \"{o} ö umlaut, trema or dieresis
r"\\r\{(\S{1})\}" => s"\1\u30A", # \r{a} å ring over the letter (for å there is also the special command \aa)
r"\\H\{(\S{1})\}" => s"\1\u30B", # \H{o} ő long Hungarian umlaut (double acute)
r"\\v\{(\S{1})\}" => s"\1\u30C", # \v{s} š caron/háček ("v") over the letter
r"\\d\{(\S{1})\}" => s"\1\u323", # \d{u} ụ dot under the letter
r"\\c\{(\S{1})\}" => s"\1\u327", # \c{c} ç cedilla
r"\\k\{(\S{1})\}" => s"\1\u328", # \k{a} ą ogonek
r"\\b\{(\S{1})\}" => s"\1\u331", # \b{b} ḇ bar under the letter
r"\\t\{(\S{1})(\S{1})\}" => s"\1\u0361\2", # \t{oo} o͡o "tie" (inverted u) over the two letters
r"\{\}" => s"", # empty curly braces should not have any effect
r"\\o" => s"\u00F8", # \o ø latin small letter O with stroke
r"\\O" => s"\u00D8", # \O Ø latin capital letter O with stroke
r"\\l" => s"\u0142", # \l ł latin small letter L with stroke
r"\\L" => s"\u0141", # \L Ł latin capital letter L with stroke
r"\\i" => s"\u0131", # \i ı latin small letter dotless I
r"\{([[:alnum:]]+)\}" => s"\1", # {<text>} <text> bracket stripping after applying all rules

# TODO:
# \t{oo} o͡o "tie" (inverted u) over the two letters
# \"{\i} ï Latin Small Letter I with Diaeresis

# Sources : https://www.compart.com/en/unicode/U+0131 enter the unicode character into the search box
Expand Down
4 changes: 3 additions & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ using Test
@testset "tex2unicode" begin
@test DocumenterCitations.tex2unicode("-- ---") == "– —"
@test DocumenterCitations.tex2unicode(
raw"\`{o}\'{o}\^{o}\~{o}\={o}\u{o}\.{o}\\\"{o}\r{a}\H{o}\v{s}\d{u}\c{c}\k{a}\b{b}\~{a}") == "òóôõōŏȯöåőšụçąḇã"
raw"\`{o}\'{o}\^{o}\~{o}\={o}\u{o}\.{o}\\\"{o}\r{a}\H{o}\v{s}\d{u}\c{c}\k{a}\b{b}\~{a}") == "òóôõōŏȯöåőšụçąḇã"
@test DocumenterCitations.tex2unicode(
raw"\i{}\o{}\O{}\l{}\L{}\i\o\O\l\L") == "ıøØłŁıøØłŁ"
@test DocumenterCitations.tex2unicode(
raw"\t{oo}{testText}\t{az}") == "o͡otestTexta͡z"
end

2 comments on commit a5513b0

@LazyScholar
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/40596

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.2.9 -m "<description of version>" a5513b091b984aea0c4753eb2a984174989da2e6
git push origin v0.2.9

Please sign in to comment.