git.iko.soy/typeable/pandoc
on master help sign in
Add LaTeX xspace support (#3797)
commit911b63dfc371541700ea16708dc66725b02393f1 authorschrieveslaach <schrieveslaach@online.de> dateThu 13 Jul 2017, 20:56 (9 years ago) parent8b502dd
2 files changed+39
src/Text/Pandoc/Readers/LaTeX.hs+12 test/command/3681.md+27
src/Text/Pandoc/Readers/LaTeX.hs+12
@@ -607,6 +607,16 @@ mkImage options src = do
607607 return $ imageWith attr (addExtension src defaultExt) "" alt
608608 _ -> return $ imageWith attr src "" alt
609609
610+doxspace :: PandocMonad m => LP m Inlines
611+doxspace = do
612+ (space <$ lookAhead (satisfyTok startsWithLetter)) <|> return mempty
613+ where startsWithLetter (Tok _ Word t) =
614+ case T.uncons t of
615+ Just (c, _) | isLetter c -> True
616+ _ -> False
617+ startsWithLetter _ = False
618+
619+
610620-- converts e.g. \SI{1}[\$]{} to "$ 1" or \SI{1}{\euro} to "1 €"
611621dosiunitx :: PandocMonad m => LP m Inlines
612622dosiunitx = do
@@ -1336,6 +1346,8 @@ inlineCommands = M.fromList $
13361346 -- fontawesome
13371347 , ("faCheck", lit "\10003")
13381348 , ("faClose", lit "\10007")
1349+ -- xspace
1350+ , ("xspace", doxspace)
13391351 ]
13401352
13411353ttfamily :: PandocMonad m => LP m Inlines
test/command/3681.mdnew file+27
@@ -0,0 +1,27 @@
1+```
2+% pandoc -f latex -t native
3+\newcommand{\cicd}{CI/CD\xspace}
4+
5+Software developers create \cicd pipelines to… Following issue can be resolved by \cicd:
6+^D
7+[Para [Str "Software",Space,Str "developers",Space,Str "create",Space,Str "CI/CD",Space,Str "pipelines",Space,Str "to\8230",Space,Str "Following",Space,Str "issue",Space,Str "can",Space,Str "be",Space,Str "resolved",Space,Str "by",Space,Str "CI/CD:"]]
8+```
9+
10+```
11+% pandoc -f latex -t native
12+\newcommand{\cicd}{CI/CD\xspace}
13+
14+\cicd\footnote{\url{https://en.wikipedia.org/wiki/CI/CD}} is awesome.
15+^D
16+[Para [Str "CI/CD",Note [Para [Link ("",[],[]) [Str "https://en.wikipedia.org/wiki/CI/CD"] ("https://en.wikipedia.org/wiki/CI/CD","")]],Space,Str "is",Space,Str "awesome."]]
17+```
18+
19+```
20+% pandoc -f latex -t native
21+\newcommand{\cicd}{CI/CD\xspace}
22+\newcommand{\pipeline}{pipeline\xspace}
23+
24+\cicd\pipeline.
25+^D
26+[Para [Str "CI/CD",Space,Str "pipeline."]]
27+```