git.iko.soy/typeable/pandoc
on master help sign in
LaTeX reader: support enquote*, foreignquote, hypphenquote...
a733068John MacFarlane
src/Text/Pandoc/Readers/LaTeX.hs+24−6
@@ -975,13 +975,22 @@ quoted' f starter ender = do
975 cs -> cs)
975 cs -> cs)
976 else lit startchs
976 else lit startchs
977
977
978−enquote :: PandocMonad m => LP m Inlines
978+enquote :: PandocMonad m => Bool -> Maybe Text -> LP m Inlines
979−enquote = do
979+enquote starred mblang = do
980 skipopts
980 skipopts
981+ let lang = (T.unpack <$> mblang) >>= babelLangToBCP47
982+ let langspan = case lang of
983+ Nothing -> id
984+ Just l -> spanWith ("",[],[("lang", renderLang l)])
981 quoteContext <- sQuoteContext <$> getState
985 quoteContext <- sQuoteContext <$> getState
982− if quoteContext == InDoubleQuote
986+ if starred || quoteContext == InDoubleQuote
983− then singleQuoted <$> withQuoteContext InSingleQuote tok
987+ then singleQuoted . langspan <$> withQuoteContext InSingleQuote tok
984− else doubleQuoted <$> withQuoteContext InDoubleQuote tok
988+ else doubleQuoted . langspan <$> withQuoteContext InDoubleQuote tok
989+
990+blockquote :: PandocMonad m => LP m Blocks
991+blockquote = do
992+ bs <- grouped block
993+ return $ blockQuote bs
985
994
986doAcronym :: PandocMonad m => String -> LP m Inlines
995doAcronym :: PandocMonad m => String -> LP m Inlines
987doAcronym form = do
996doAcronym form = do
@@ -1769,7 +1778,14 @@ inlineCommands = M.union inlineLanguageCommands $ M.fromList
1769 src <- unescapeURL . T.unpack .
1778 src <- unescapeURL . T.unpack .
1770 removeDoubleQuotes . untokenize <$> braced
1779 removeDoubleQuotes . untokenize <$> braced
1771 mkImage options src)
1780 mkImage options src)
1772− , ("enquote", enquote)
1781+ , ("enquote*", enquote True Nothing)
1782+ , ("enquote", enquote False Nothing)
1783+ -- foreignquote is supposed to use native quote marks
1784+ , ("foreignquote*", braced >>= enquote True . Just . untokenize)
1785+ , ("foreignquote", braced >>= enquote False . Just . untokenize)
1786+ -- hypehnquote uses regular quotes
1787+ , ("hyphenquote*", braced >>= enquote True . Just . untokenize)
1788+ , ("hyphenquote", braced >>= enquote False . Just . untokenize)
1773 , ("figurename", doTerm Translations.Figure)
1789 , ("figurename", doTerm Translations.Figure)
1774 , ("prefacename", doTerm Translations.Preface)
1790 , ("prefacename", doTerm Translations.Preface)
1775 , ("refname", doTerm Translations.References)
1791 , ("refname", doTerm Translations.References)
@@ -2524,6 +2540,8 @@ blockCommands = M.fromList
2524 -- LaTeX colors
2540 -- LaTeX colors
2525 , ("textcolor", coloredBlock "color")
2541 , ("textcolor", coloredBlock "color")
2526 , ("colorbox", coloredBlock "background-color")
2542 , ("colorbox", coloredBlock "background-color")
2543+ -- csquotse
2544+ , ("blockquote", blockquote)
2527 -- include
2545 -- include
2528 , ("include", include "include")
2546 , ("include", include "include")
2529 , ("input", include "input")
2547 , ("input", include "input")
test/command/4848.mdnew file+58
@@ -0,0 +1,58 @@
1+```
2+% pandoc -f latex -t native
3+\enquote*{hi}
4+^D
5+[Para [Quoted SingleQuote [Str "hi"]]]
6+```
7+
8+```
9+% pandoc -f latex -t native
10+\foreignquote{italian}{hi}
11+^D
12+[Para [Quoted DoubleQuote [Span ("",[],[("lang","it")]) [Str "hi"]]]]
13+```
14+
15+```
16+% pandoc -f latex -t native
17+\hyphenquote*{italian}{hi}
18+^D
19+[Para [Quoted SingleQuote [Span ("",[],[("lang","it")]) [Str "hi"]]]]
20+```
21+
22+```
23+% pandoc -f latex -t native
24+Lorem ipsum
25+\blockquote{dolor sit amet}
26+consectetuer.
27+^D
28+[Para [Str "Lorem",Space,Str "ipsum"]
29+,BlockQuote
30+ [Para [Str "dolor",Space,Str "sit",Space,Str "amet"]]
31+,Para [Str "consectetuer."]]
32+```
33+
34+```
35+% pandoc -f latex -t native
36+Lorem ipsum
37+\blockcquote[198]{Knu86}{dolor sit amet}
38+consectetuer.
39+^D
40+[Para [Str "Lorem",Space,Str "ipsum"]
41+,BlockQuote
42+ [Para [Str "dolor",Space,Str "sit",Space,Str "amet",Space,Cite [Citation {citationId = "Knu86", citationPrefix = [], citationSuffix = [Str "198"], citationMode = NormalCitation, citationNoteNum = 0, citationHash = 0}] [RawInline (Format "latex") "\\cite[198]{Knu86}"]]]
43+,Para [Str "consectetuer."]]
44+```
45+
46+```
47+% pandoc -f latex -t native
48+Lorem ipsum
49+\foreignblockquote{italian}{dolor sit amet}
50+consectetuer.
51+^D
52+[Para [Str "Lorem",Space,Str "ipsum"]
53+,Div ("",[],[("lang","it")])
54+ [BlockQuote
55+ [Para [Str "dolor",Space,Str "sit",Space,Str "amet"]]]
56+,Para [Str "consectetuer."]]
57+```
58+