LaTeX reader: Support more text-mode accents.

Add support for `\|`, `\b`, `\G`, `\h`, `\d`, `\f`,
`\r`, `\t`, `\U`, `\i`, `\j`, `\newtie`, `\textcircled`.

Also fall back to combining characters when composed
characters are not available.

Closes #4652.
This commit is contained in:
John MacFarlane 2018-08-17 23:19:38 -07:00
parent 159863e8da
commit 42f4632e60
2 changed files with 95 additions and 5 deletions

View file

@ -1214,6 +1214,84 @@ macron 'o' = "ō"
macron 'u' = "ū"
macron c = [c]
ringabove :: Char -> String
ringabove 'A' = "Å"
ringabove 'a' = "å"
ringabove 'U' = "Ů"
ringabove 'u' = "ů"
ringabove c = [c]
dotbelow :: Char -> String
dotbelow 'B' = ""
dotbelow 'b' = ""
dotbelow 'D' = ""
dotbelow 'd' = ""
dotbelow 'H' = ""
dotbelow 'h' = ""
dotbelow 'K' = ""
dotbelow 'k' = ""
dotbelow 'L' = ""
dotbelow 'l' = ""
dotbelow 'M' = ""
dotbelow 'm' = ""
dotbelow 'N' = ""
dotbelow 'n' = ""
dotbelow 'R' = ""
dotbelow 'r' = ""
dotbelow 'S' = ""
dotbelow 's' = ""
dotbelow 'T' = ""
dotbelow 't' = ""
dotbelow 'V' = ""
dotbelow 'v' = "ṿ"
dotbelow 'W' = ""
dotbelow 'w' = ""
dotbelow 'Z' = ""
dotbelow 'z' = ""
dotbelow 'A' = ""
dotbelow 'a' = ""
dotbelow 'E' = ""
dotbelow 'e' = ""
dotbelow 'I' = ""
dotbelow 'i' = ""
dotbelow 'O' = ""
dotbelow 'o' = ""
dotbelow 'U' = ""
dotbelow 'u' = ""
dotbelow 'Y' = ""
dotbelow 'y' = ""
dotbelow c = [c]
doublegrave :: Char -> String
doublegrave 'A' = "Ȁ"
doublegrave 'a' = "ȁ"
doublegrave 'E' = "Ȅ"
doublegrave 'e' = "ȅ"
doublegrave 'I' = "Ȉ"
doublegrave 'i' = "ȉ"
doublegrave 'O' = "Ȍ"
doublegrave 'o' = "ȍ"
doublegrave 'R' = "Ȑ"
doublegrave 'r' = "ȑ"
doublegrave 'U' = "Ȕ"
doublegrave 'u' = "ȕ"
doublegrave c = [c]
hookabove :: Char -> String
hookabove 'A' = ""
hookabove 'a' = ""
hookabove 'E' = ""
hookabove 'e' = ""
hookabove 'I' = ""
hookabove 'i' = ""
hookabove 'O' = ""
hookabove 'o' = ""
hookabove 'U' = ""
hookabove 'u' = ""
hookabove 'Y' = ""
hookabove 'y' = ""
hookabove c = [c]
cedilla :: Char -> String
cedilla 'c' = "ç"
cedilla 'C' = "Ç"
@ -1645,12 +1723,24 @@ inlineCommands = M.union inlineLanguageCommands $ M.fromList
, ("\"", accent '\776' umlaut)
, (".", accent '\775' dot)
, ("=", accent '\772' macron)
, ("|", accent '\781' (:[])) -- vertical line above
, ("b", accent '\817' (:[])) -- macron below
, ("c", accent '\807' cedilla)
, ("G", accent '\783' doublegrave)
, ("h", accent '\777' hookabove)
, ("d", accent '\803' dotbelow)
, ("f", accent '\785' (:[])) -- inverted breve
, ("r", accent '\778' ringabove)
, ("t", accent '\865' (:[])) -- double inverted breve
, ("U", accent '\782' (:[])) -- double vertical line above
, ("v", accent 'ˇ' hacek)
, ("u", accent '\774' breve)
, ("k", accent '\808' ogonek)
, ("textogonekcentered", accent '\808' ogonek)
, ("i", lit "i")
, ("i", lit "ı") -- dotless i
, ("j", lit "ȷ") -- dotless j
, ("newtie", accent '\785' (:[])) -- inverted breve
, ("textcircled", accent '\8413' (:[])) -- combining circle
, ("\\", linebreak <$ (do inTableCell <- sInTableCell <$> getState
guard $ not inTableCell
optional opt

View file

@ -24,18 +24,18 @@ expanded at point of use:
% pandoc -f latex -t latex
\let\a\b
\newcommand{\b}{\emph{ouk}}
\a
\a a
^D
\b
```
```
% pandoc -f latex -t latex
\newcommand{\a}{\b}
\newcommand{\b}{\emph{ouk}}
\a
\a a
^D
\emph{ouk}
\emph{ouk}a
```
```