Skip to content

Commit

Permalink
Merge pull request #12 from Omikhleia/smart-quotations-mark
Browse files Browse the repository at this point in the history
feat: Smart typography takes language into account for quotation marks
  • Loading branch information
Omikhleia authored Nov 12, 2022
2 parents bf66cd7 + fce43dd commit 2f69ba1
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 3 deletions.
8 changes: 8 additions & 0 deletions examples/sile-and-markdown.md
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,14 @@ This was obtained with:
Or inline in text: [«Encore du français!»]{lang=fr}
```

Smart typography takes the current language into account when converting straight double and single
quotation marks to the appropriate typographic variant:
["English"]{lang=en} / ["Deutsch"]{lang=de} / ["français"]{lang=fr} / ["dansk"]{lang=da} / ["русский"]{lang=ru};
['English']{lang=en} / ['Deutsch']{lang=de} / ['français']{lang=fr} / ['dansk']{lang=da} / ['русский']{lang=ru}.^[For
most languages, `"` and `'` correspond to the primary and secondary quotations marks, respectively.
In some languages, they are used the other way round, but obviously the user's input is respected in those cases
(e.g. respectively ["Ghàidhlig"]{lang=cy} and ['Ghàidhlig']{lang=cy}).]

### Custom styles

On the "div" and "span" extended elements, the converter also supports the `{custom-style="..."}`
Expand Down
2 changes: 2 additions & 0 deletions inputters/markdown.lua
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ local function SileAstWriter (options)
writer.verbatim = simpleCommandWrapper("verbatim")
writer.listitem = simpleCommandWrapper("item")
writer.linebreak = simpleCommandWrapper("cr")
writer.singlequoted = simpleCommandWrapper("singlequoted")
writer.doublequoted = simpleCommandWrapper("doublequoted")

-- Special case for hrule (simple too, but arguments from lunamark has to be ignored)
writer.hrule = function () return utils.createCommand("fullrule") end
Expand Down
5 changes: 3 additions & 2 deletions inputters/pandocast.lua
Original file line number Diff line number Diff line change
Expand Up @@ -426,10 +426,11 @@ end
-- Quoted QuoteType [Inline]
-- Where QuoteType is a tag DoubleQuote or SingleQuote
Pandoc.Quoted = function (quotetype, inlines)
local content = pandocAstParse(inlines)
if quotetype.t == "DoubleQuote" then
return pandocAstParse({ "", inlines, "" })
return utils.createCommand("doublequoted", {}, content)
end
return pandocAstParse({ "", inlines, "" })
return utils.createCommand("singlequoted", content)
end

-- Cite [Citation] [Inline]
Expand Down
3 changes: 2 additions & 1 deletion markdown.sile-dev-1.rockspec
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ description = {
dependencies = {
"lua >= 5.1",
"ptable.sile",
"textsubsuper.sile"
"textsubsuper.sile",
"smartquotes.sile"
}

build = {
Expand Down
1 change: 1 addition & 0 deletions packages/markdown/commands.lua
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ function package:_init (_)
self.class:loadPackage("lists")
self.class:loadPackage("ptable")
self.class:loadPackage("rules")
self.class:loadPackage("smartquotes")
self.class:loadPackage("svg")
self.class:loadPackage("textsubsuper")
self.class:loadPackage("url")
Expand Down

0 comments on commit 2f69ba1

Please sign in to comment.