mirror of
https://github.com/jgm/pandoc.git
synced 2026-08-30 17:59:17 +08:00
@@ -82,16 +82,6 @@ $endif$
|
||||
|
||||
$body$
|
||||
|
||||
$if(notes)$
|
||||
#v(1em)
|
||||
#block[
|
||||
#horizontalrule
|
||||
#set text(size: .88em)
|
||||
#v(3pt) // otherwise first note marker is swallowed, bug?
|
||||
|
||||
$notes$
|
||||
]
|
||||
$endif$
|
||||
$if(citations)$
|
||||
$if(bibliographystyle)$
|
||||
|
||||
|
||||
@@ -43,8 +43,7 @@ writeTypst :: PandocMonad m => WriterOptions -> Pandoc -> m Text
|
||||
writeTypst options document =
|
||||
evalStateT (pandocToTypst options document)
|
||||
WriterState{ stOptions = options,
|
||||
stEscapeContext = NormalContext,
|
||||
stNotes = [] }
|
||||
stEscapeContext = NormalContext }
|
||||
|
||||
data EscapeContext = NormalContext | TermContext
|
||||
deriving (Show, Eq)
|
||||
@@ -52,9 +51,7 @@ data EscapeContext = NormalContext | TermContext
|
||||
data WriterState =
|
||||
WriterState {
|
||||
stOptions :: WriterOptions,
|
||||
stEscapeContext :: EscapeContext,
|
||||
stNotes :: [Doc Text]
|
||||
}
|
||||
stEscapeContext :: EscapeContext }
|
||||
|
||||
type TW m = StateT WriterState m
|
||||
|
||||
@@ -69,14 +66,7 @@ pandocToTypst options (Pandoc meta blocks) = do
|
||||
(fmap chomp . inlinesToTypst)
|
||||
meta
|
||||
main <- blocksToTypst blocks
|
||||
noteContents <- reverse <$> gets stNotes
|
||||
let notes = vsep $ zipWith
|
||||
(\(num :: Int) cont ->
|
||||
"#endnote" <> parens (brackets (text (show num))
|
||||
<> ", " <> brackets (chomp cont <> cr)))
|
||||
[1..] noteContents
|
||||
let context = defField "body" main
|
||||
$ defField "notes" notes
|
||||
$ defField "toc" (writerTableOfContents options)
|
||||
$ (if isEnabled Ext_citations options
|
||||
then defField "citations" True
|
||||
@@ -291,12 +281,9 @@ inlineToTypst inline =
|
||||
let height' = maybe mempty ((", height: " <>) . literal) $
|
||||
lookup "height" kvs
|
||||
return $ "#image(" <> doubleQuoted src <> width' <> height' <> ")"
|
||||
Note blocks -> do -- currently typst has no footnotes!
|
||||
-- TODO create endnotes with manual typesetting
|
||||
Note blocks -> do
|
||||
contents <- blocksToTypst blocks
|
||||
modify $ \st -> st{ stNotes = contents : stNotes st }
|
||||
num <- text . show . length <$> gets stNotes
|
||||
return $ "#super" <> brackets num
|
||||
return $ "#footnote" <> brackets (chomp contents)
|
||||
|
||||
textstyle :: PandocMonad m => Doc Text -> [Inline] -> TW m (Doc Text)
|
||||
textstyle s inlines = (s <>) . brackets <$> inlinesToTypst inlines
|
||||
|
||||
+13
-34
@@ -774,29 +774,9 @@ Here is a movie #image("movie.jpg") icon.
|
||||
|
||||
= Footnotes
|
||||
<footnotes>
|
||||
Here is a footnote reference,#super[1] and another.#super[2] This should
|
||||
#emph[not] be a footnote reference, because it contains a space.\[^my note\]
|
||||
Here is an inline note.#super[3]
|
||||
|
||||
#blockquote[
|
||||
Notes can go in quotes.#super[4]
|
||||
]
|
||||
|
||||
+ And in list items.#super[5]
|
||||
|
||||
This paragraph should not be part of the note, as it is not indented.
|
||||
|
||||
#v(1em)
|
||||
#block[
|
||||
#horizontalrule
|
||||
#set text(size: .88em)
|
||||
#v(3pt) // otherwise first note marker is swallowed, bug?
|
||||
|
||||
#endnote([1], [Here is the footnote. It can go anywhere after the footnote
|
||||
reference. It need not be placed at the end of the document.
|
||||
])
|
||||
|
||||
#endnote([2], [Here’s the long note. This one contains multiple blocks.
|
||||
Here is a footnote reference,#footnote[Here is the footnote. It can go anywhere
|
||||
after the footnote reference. It need not be placed at the end of the document.]
|
||||
and another.#footnote[Here’s the long note. This one contains multiple blocks.
|
||||
|
||||
Subsequent blocks are indented to show that they belong to the footnote (as with
|
||||
list items).
|
||||
@@ -806,17 +786,16 @@ list items).
|
||||
```
|
||||
|
||||
If you want, you can indent every line, but you can also be lazy and just indent
|
||||
the first line of each block.
|
||||
])
|
||||
|
||||
#endnote([3], [This is #emph[easier] to type. Inline notes may contain
|
||||
the first line of each block.] This should #emph[not] be a footnote reference,
|
||||
because it contains a space.\[^my note\] Here is an inline note.#footnote[This
|
||||
is #emph[easier] to type. Inline notes may contain
|
||||
#link("http://google.com")[links] and `]` verbatim characters, as well as
|
||||
\[bracketed text\].
|
||||
])
|
||||
\[bracketed text\].]
|
||||
|
||||
#endnote([4], [In quote.
|
||||
])
|
||||
|
||||
#endnote([5], [In list.
|
||||
])
|
||||
#blockquote[
|
||||
Notes can go in quotes.#footnote[In quote.]
|
||||
]
|
||||
|
||||
+ And in list items.#footnote[In list.]
|
||||
|
||||
This paragraph should not be part of the note, as it is not indented.
|
||||
|
||||
Reference in New Issue
Block a user