dialoa / statement

Statement - theorems and statement support in Pandoc's markdown
https://dialoa.github.io/statement/
MIT License
17 stars 1 forks source link

Cite cross different html files #10

Closed neozhaoliang closed 11 months ago

neozhaoliang commented 11 months ago

Hi, I'm using pandoc to convert a folder of markdown files to HTML, with each markdown to one HTML. How can I refer to a statement in a different markdown file?

For example, in file A.md, I have a statement like

::: {.theorem #einstein}
Einstein
:::

And in file B.md, I want to cite the theorem as

See @Pre:einstein.

If the output is a standalone big HTML, then the above way works. But if there are many generated HTML files, the link in B.html to the theorem is broken. How can I fix this?

twsh commented 11 months ago

Have you looked at Pandoc's Chunked HTML? I don't know if it's exactly what you want, but it can give you a directory of HTML files with links between them.

neozhaoliang commented 11 months ago

@twsh Thank you! Using the - t chunkedhtml option worked!

I have another problem here, it's not related to the chunked HTML option, it also happens when a standalone file is created: the theorems are not labeled according to the sections, for example, theorem 3.1 or theorem 4.2, instead, everything got numbered without the section headings, like proposition 1, theorem 2, lemme 3, corollary 4, ... etc.

Below is my metadata config for statement, I guess the count-within option is not working as expected?

statement:
  supply-header: no
  count-within: section
  crossref-prefixes: true
statement-kinds:
  theorem:
    label: 定理
    counter: theorem
  lemma:
    label: 引理
    counter: theorem
  proposition:
    label: 命题
    counter: theorem
  corollary:
    label: 推论
    counter: theorem
  definition:
    label: 定义
    counter: none
    style: definition
  proof:
    label: 证明
    counter: none
    style: proof
  note:
    label: 注记
    counter: none
    style: note
  example:
    label: 例
    counter: none
    style: definition
statement-styles:
    definition:
      punctuation: ':'
    note:
      punctuation: ':'

And my pandoc args are:

--split-level=2 --template templates/html.html -L statement/statement.lua --to html5 --citeproc --highlight-style=breezedark --number-sections --section-divs -t chunkedhtml
twsh commented 11 months ago

I just tried an example where I took out 'counter' from the theorem kind and it seemed to work. Does that work for your more complex document?

---
statement:
  count-within: section
statement-kinds:
  theorem:
    label: 定理
---

# Section one

::: {.theorem #one}
One
:::

# Section two

::: {.theorem #two}
Two
:::

see @Pre:one
neozhaoliang commented 11 months ago

@twsh Oh yes, it also worked. You helped me tremendously and my heartfelt thanks to you!