chdemko / pandoc-latex-environment

Pandoc filter for adding LaTeX environement on specific div
https://pandoc-latex-environment.readthedocs.io/
BSD 3-Clause "New" or "Revised" License
33 stars 9 forks source link

Problème avec <div id="refs"> #1

Closed hugoroy closed 8 years ago

hugoroy commented 8 years ago

Il semble y avoir un conflit avec <div id="refs">

Par exemple, un document produit d'abord avec le filtre pandoc-citeproc puis avec le filtre pandoc-latex-environement contenant :


---
header-includes:
  - \newenvironment{loi}{\begin{quote}\sffamily\itshape}{\end{quote}}
  - \newenvironment{parl}{\begin{quote}\itshape}{\end{quote}}
  - \newenvironment{jpref}{\sffamily\parindent 0pt \noindent}{}
latex-environment:
  loi: [loi, law]
  parl: [parl]
  jpref: [jpref]
...

<div id="refs" class="jpref"></div>

Produira :

\hyperdef{}{refs}{\label{refs}}
\begin{jpref}

\hyperdef{}{ref-cjueERT}{\label{ref-cjueERT}}
\begin{jpref}

CJUE, 18 juin 1991, \emph{Elliniki Radiophonia Tiléorassi AE et
Panellinia Omospondia Syllogon Prossopikou contre Dimotiki Etairia
Pliroforissis et Sotirios Kouvelas et Nicolaos Avdellas et autres.},
C-260/89

\end{jpref}

\hyperdef{}{ref-cjueAklagaren}{\label{ref-cjueAklagaren}}
\begin{jpref}

CJUE, g\textsuperscript{de}~ch., 26 févr. 2013, \emph{Åklagaren contre
Hans Åkerberg Fransson}, C-617/10

\end{jpref}

\hyperdef{}{ref-cjuePfleger}{\label{ref-cjuePfleger}}
\begin{jpref}

CJUE, 3\textsuperscript{e}~ch., 30 avr. 2014, \emph{Pfleger et autres},
C-390/12

\end{jpref}

\end{jpref}

Le problème se pose aussi simplement avec <div id="refs">

chdemko commented 8 years ago

Je n'ai pas ce soucis ici:

$ pandoc --filter pandoc-citeproc --filter pandoc-latex-environment -t latex

Avec

---
header-includes:
  - \newenvironment{loi}{\begin{quote}\sffamily\itshape}{\end{quote}}
  - \newenvironment{parl}{\begin{quote}\itshape}{\end{quote}}
  - \newenvironment{jpref}{\sffamily\parindent 0pt \noindent}{}
latex-environment:
  loi: [loi, law]
  parl: [parl]
  jpref: [jpref]
...

<div id="refs" class="jpref"></div>

produit

\hypertarget{refs}{}
\begin{jpref}

\end{jpref}
hugoroy commented 8 years ago

Il faut spécifier une bibliographie et citer une référence bibliographique (sinon pandoc-citeproc ne fait rien)

---
header-includes:
  - \newenvironment{loi}{\begin{quote}\sffamily\itshape}{\end{quote}}
  - \newenvironment{parl}{\begin{quote}\itshape}{\end{quote}}
  - \newenvironment{jpref}{\sffamily\parindent 0pt \noindent}{}
latex-environment:
  loi: [loi, law]
  parl: [parl]
  jpref: [jpref]
references:
- type: article-journal
  id: WatsonCrick1953
  author:
  - family: Watson
    given: J. D.
  - family: Crick
    given: F. H. C.
  issued:
    date-parts:
    - - 1953
      - 4
      - 25
  title: 'Molecular structure of nucleic acids: a structure for deoxyribose
    nucleic acid'
  title-short: Molecular structure of nucleic acids
  container-title: Nature
  volume: 171
  issue: 4356
  page: 737-738
  DOI: 10.1038/171737a0
  URL: http://www.nature.com/nature/journal/v171/n4356/abs/171737a0.html
  language: en-GB
...

@WatsonCrick1953

<div id="refs" class="jpref"></div>

donnera

Watson and Crick (1953)

\hyperdef{}{refs}{\label{refs}}
\begin{jpref}

\hyperdef{}{ref-WatsonCrick1953}{\label{ref-WatsonCrick1953}}
\begin{parl}

Watson, J. D., and F. H. C. Crick. 1953. ``Molecular Structure of
Nucleic Acids: A Structure for Deoxyribose Nucleic Acid.'' \emph{Nature}
171 (4356): 737--38.
doi:\href{http://doi.org/10.1038/171737a0}{10.1038/171737a0}.

\end{parl}

\end{jpref}
chdemko commented 8 years ago

It was because pandoc-citeproc generates div whose classes are empty. I've added a test for dealing with div without classes. Fixed in 0.0.3

chdemko commented 8 years ago

Previous code was incorrect. Fixed in 0.0.4

chdemko commented 8 years ago

Becarefull

  loi: [loi, law]

means classes must contains loi and law

hugoroy commented 8 years ago

Oui j'ai modifié :-)

Merci