LaTeX reader: Add basic support for hyphenat package (#3603)

This commit is contained in:
schrieveslaach 2017-04-26 12:05:13 +02:00 committed by John MacFarlane
parent 256e3a6a5d
commit a29fa15a7b
2 changed files with 62 additions and 1 deletions

View file

@ -518,7 +518,7 @@ inlineCommands = M.fromList $
, ("textmd", extractSpaces (spanWith ("",["medium"],[])) <$> tok) , ("textmd", extractSpaces (spanWith ("",["medium"],[])) <$> tok)
, ("textrm", extractSpaces (spanWith ("",["roman"],[])) <$> tok) , ("textrm", extractSpaces (spanWith ("",["roman"],[])) <$> tok)
, ("textup", extractSpaces (spanWith ("",["upright"],[])) <$> tok) , ("textup", extractSpaces (spanWith ("",["upright"],[])) <$> tok)
, ("texttt", (code . stringify . toList) <$> tok) , ("texttt", ttfamily)
, ("sout", extractSpaces strikeout <$> tok) , ("sout", extractSpaces strikeout <$> tok)
, ("textsuperscript", extractSpaces superscript <$> tok) , ("textsuperscript", extractSpaces superscript <$> tok)
, ("textsubscript", extractSpaces subscript <$> tok) , ("textsubscript", extractSpaces subscript <$> tok)
@ -671,6 +671,15 @@ inlineCommands = M.fromList $
, ("hypertarget", braced >> tok) , ("hypertarget", braced >> tok)
-- siuntix -- siuntix
, ("SI", dosiunitx) , ("SI", dosiunitx)
-- hyphenat
, ("bshyp", lit "\\\173")
, ("fshyp", lit "/\173")
, ("dothyp", lit ".\173")
, ("colonhyp", lit ":\173")
, ("hyp", lit "-")
, ("nohyphens", tok)
, ("textnhtt", ttfamily)
, ("nhttfamily", ttfamily)
] ++ map ignoreInlines ] ++ map ignoreInlines
-- these commands will be ignored unless --parse-raw is specified, -- these commands will be ignored unless --parse-raw is specified,
-- in which case they will appear as raw latex blocks: -- in which case they will appear as raw latex blocks:
@ -682,6 +691,9 @@ inlineCommands = M.fromList $
, "pagebreak" , "pagebreak"
] ]
ttfamily :: PandocMonad m => LP m Inlines
ttfamily = (code . stringify . toList) <$> tok
mkImage :: PandocMonad m => [(String, String)] -> String -> LP m Inlines mkImage :: PandocMonad m => [(String, String)] -> String -> LP m Inlines
mkImage options src = do mkImage options src = do
let replaceTextwidth (k,v) = case numUnit v of let replaceTextwidth (k,v) = case numUnit v of

49
test/command/hyphenat.md Normal file
View file

@ -0,0 +1,49 @@
```
% pandoc -f latex -t native
electromagnetic\hyp{}endioscopy
^D
[Para [Str "electromagnetic-endioscopy"]]
```
```
% pandoc -f latex -t native
C\colonhyp\bshyp{}Windows\bshyp
^D
[Para [Str "C:\173\\\173Windows\\\173"]]
```
```
% pandoc -f latex -t native
\fshyp{}usr\fshyp{}share\fshyp
^D
[Para [Str "/\173usr/\173share/\173"]]
```
```
% pandoc -f latex -t native
\fshyp{}home\fshyp{}schrieveslaach\fshyp\dothyp{}m2
^D
[Para [Str "/\173home/\173schrieveslaach/\173.\173m2"]]
```
```
% pandoc -f latex -t native
\nohyphens{Pneumonoultramicroscopicsilicovolcanoconiosis}
^D
[Para [Str "Pneumonoultramicroscopicsilicovolcanoconiosis"]]
```
```
% pandoc -f latex -t native
\textnhtt{Pneumonoultramicroscopicsilicovolcanoconiosis}
^D
[Para [Code ("",[],[]) "Pneumonoultramicroscopicsilicovolcanoconiosis"]]
```
```
% pandoc -f latex -t native
\nhttfamily{Pneumonoultramicroscopicsilicovolcanoconiosis}
^D
[Para [Code ("",[],[]) "Pneumonoultramicroscopicsilicovolcanoconiosis"]]
```