Git Product home page Git Product logo

pandoc-xnos's Introduction

pandoc-xnos

The pandoc-xnos filter suite provides facilities for cross-referencing in markdown documents processed by pandoc. Individual filters are maintained in separate projects. They are:

Click on the above links to access documentation for each filter. LaTeX/pdf, html, and epub output have native support. Native support for docx output is a work in progress.

This project provides library code for the suite and a pandoc-xnos filter that applies all of the above filters in sequence.

See also: pandoc-comments, pandoc-latex-extensions

Contents

  1. Installation
  2. Usage
  3. Getting Help

Installation

The Pandoc-xnos filters require python. It is easily installed -- see here. 1 Either python 2.7 or 3.x will do.

The pandoc-xnos filter suite may be installed using the shell command

pip install pandoc-fignos pandoc-eqnos pandoc-tablenos \
            pandoc-secnos --user

and upgraded by appending --upgrade to the above command.

Pip is a program that downloads and installs software from the Python Package Index, PyPI.

Instructions for installing from source are given in DEVELOPERS.md.

Usage

The pandoc-xnos filter suite may be applied using the

--filter pandoc-xnos

option with pandoc. It is also possible to apply the filters individually.

Any use of --filter pandoc-citeproc or --bibliography=FILE should come after the pandoc-xnos filter call.

Getting Help

If you have any difficulties with pandoc-xnos, or would like to see a new feature, then please submit a report to our Issues tracker.


Footnotes

1: For MacOS, my preferred install method is to use the Installer package available from python.org.

pandoc-xnos's People

Contributors

jschlatow avatar timtroendle avatar tomduck avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

pandoc-xnos's Issues

`--filter pandoc-xnos` ignoring figure reference

I'm trying to convert a .md file (thesis chapter with references) into a .pdf using pandoc and pandoc-xnos. My makefile contains the following:

%.pdf : %.md
	@echo --- Generating PDF ---
	@pandoc --filter pandoc-xnos --citeproc \
	 --bibliography ../../../zotero_lib_betterbibtex/MyLibrary.bib --csl ../chicago.csl \
	 -V papersize:letter -V linestretch:1.5 -V geometry:margin=2.54cm -V numbersections:true \
	 --pdf-engine xelatex -o $@ $<

but for some reason when I execute it, I get the following warning:

[WARNING] Citeproc: citation fig:fig1 not found

This suggests that pandoc-xnos is ignoring the figure references, even though I've specified my figures appropriately in the markdown file:

image

Do you have any ideas as to what's going on? I should note that I tried putting the in-text reference to the figure in curly braces and the same warning came up.

Feature: allow passing path to pandoc in init()

I'd like to be able to pass the path to pandoc to init and have init figure out the pandoc version:

pversion = pandocxnos.init(local_path='../my/local/dir/pandoc')

This would allow me to reference a portable version of pandoc without putting it in the path.

TypeError: write() argument 1 must be unicode, not str

Hi, I'm having trouble running pandoc-xnos on macOs Big Sur with Python 2.7. I'm getting the following error:

[INFO] Running filter pandoc-shortcaption
[INFO] Completed filter pandoc-shortcaption in 128 ms
[INFO] Running filter pandoc-xnos
Traceback (most recent call last):
  File "/Users/eddyc/Library/Python/2.7/bin/pandoc-xnos", line 8, in <module>
    sys.exit(main())
  File "/Users/eddyc/Library/Python/2.7/lib/python/site-packages/pandocxnos/main.py", line 38, in main
    m.main(stdin, stdout)
  File "/Users/eddyc/Library/Python/2.7/lib/python/site-packages/pandoc_fignos.py", line 663, in main
    json.dump(doc, stdout)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/__init__.py", line 190, in dump
    fp.write(chunk)
TypeError: write() argument 1 must be unicode, not str
Error running filter pandoc-xnos:
Filter returned error status 1

Is pandoc-xnos.exe a Haskell or Python exe?

I'm curious to know what/where the source of the pandoc-xnos.exe is? Is it a Python script packaged as an executable or is it compiled in some other language?

Many thanks.

Feature request: xnos-non-breaking customisation

This is a feature request for a general xnos-non-breaking customisation,
with child customisations fignos-non-breaking, tablenos-non-breaking, etc.

Setting this --metadata variable to True,

-M xnos-non-breaking=True

would replace the standard whitespace between, for example, "Fig. 1" with a non-breaking space in the different output formats. That would be ~ for LaTeX, &nbsp; for (X)HTML, and U+00A0 in Unicode.

This should affect all names; i.e. xnos-plus-name, xnos-star-name and xnos-caption-name.

However, this should not affect the xnos-caption-separator, which is already controlled separately.
Adding non-breaking as an allowed value for xnos-caption-separator would take care of this specific caption separator.

Caption inside link

Hello,

When generating a clever reference to a figure/table/section/equation, is it possible to place the caption/name (e.g. "fig") inside the link so that the text is clickable? Makes clicking the link slightly easier for the user rather than them having to click specifically on the number.

Thanks

Environment tablenos:no-prefix-table-caption undefined

Hi,

when running pandoc with --filter pandoc-xnos I get the following error:

! LaTeX Error: Environment tablenos:no-prefix-table-caption undefined.

See the LaTeX manual or LaTeX Companion for explanation.
Type H for immediate help.
...

l.654 \begin{tablenos:no-prefix-table-caption}

What is going on?

Best,

Ole

Does not work with pandoc 3.0 released recently

Hello,

xnos stopped working with the new release of pandoc 3.0.

Is there an easy fix for this?

Thanks,
Howard

Traceback (most recent call last):
File "", line 198, in _run_module_as_main
File "", line 88, in run_code
File "C:\Users\hborchew\AppData\Roaming\Python\Python311\Scripts\pandoc-xnos.exe_main
.py", line 7, in
File "C:\Users\hborchew\AppData\Roaming\Python\Python311\site-packages\pandocxnos\main.py", line 38, in main
m.main(stdin, stdout)
File "C:\Users\hborchew\AppData\Roaming\Python\Python311\site-packages\pandoc_fignos.py", line 608, in main
PANDOCVERSION = pandocxnos.init(args.pandocversion, doc)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\hborchew\AppData\Roaming\Python\Python311\site-packages\pandocxnos\core.py", line 224, in init
_PANDOCVERSION = _get_pandoc_version(pandocversion, doc)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\hborchew\AppData\Roaming\Python\Python311\site-packages\pandocxnos\core.py", line 179, in _get_pandoc_version
raise RuntimeError(msg)
RuntimeError: Cannot understand pandocversion=3.0
Error running filter pandoc-xnos.exe:
Filter returned error status 1

pandoc-xnos fails with TypeError

I am automating my work flow with the following code:

import subprocess
import os

for root, dirs, files in os.walk('./content'):
    for filename in files:
        if filename.endswith(".md") and int(filename[:2]) > 9:
            md_name = f"{root}/{filename}"
            tex_name = f"{root}/../tex/section{filename[:2]}.tex"
            print(f'generating: {tex_name}...')
            subprocess.call([
                'pandoc', 
                '-r', 
                'markdown',
                md_name,
                '--filter',
                'pandoc-xnos',
                '-o',
                tex_name
            ])

when I run this via a Makefile, I get the following output.

PS C:\...> make
python ./src/convert_to_tex.py
generating: ./content/../tex/section10.tex...
Traceback (most recent call last):
  File "C:\...\python\current\lib\runpy.py", line 194, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\...\python\current\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "C:\...\python\current\Scripts\pandoc-xnos.exe\__main__.py", line 7, in <module>
  File "C:\...\python\current\lib\site-packages\pandocxnos\main.py", line 38, in main
    m.main(stdin, stdout)
  File "C:\...\python\current\lib\site-packages\pandoc_fignos.py", line 642, in main
    altered = functools.reduce(lambda x, action: walk(x, action, fmt, meta),
  File "C:\...\python\current\lib\site-packages\pandoc_fignos.py", line 642, in <lambda>
    altered = functools.reduce(lambda x, action: walk(x, action, fmt, meta),
  File "C:\...\python\current\lib\site-packages\pandocfilters.py", line 110, in walk
    res = action(item['t'],
  File "C:\...\python\current\lib\site-packages\pandocxnos\core.py", line 856, in process_refs
    _process_refs(value[-5], pattern, labels)
  File "C:\...\python\current\lib\site-packages\pandocxnos\core.py", line 92, in wrapper
    ret = func(*args, **kwargs)
  File "C:\...\python\current\lib\site-packages\pandocxnos\core.py", line 758, in _process_refs
    if v['t'] == 'Cite' and len(v['c']) == 2:
TypeError: string indices must be integers
Error running filter pandoc-xnos:
Filter returned error status 1
PS C:\...> make

Why would this be happening? This was working fine not too long ago. I suspect an update to Pandoc may have caused the problem but I wanted to check here. It should be noted that the code works fine without the --filter pandoc-xnos option.

Bug in broken refs code

The following markdown causes pandoc-fignos to crash:

["This"], crashes fignos.

["This"]: https://google.com/

The problem occurs with the ["This"], portion. If the quotes or comma are dropped, then everything is fine. Single quotes also cause a crash.

Here is the session:

$ pandoc-1.17.2 demo2.md --filter pandoc-fignos -o out/demo2.pdf
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.4/bin/pandoc-fignos", line 9, in <module>
    load_entry_point('pandoc-fignos==0.16', 'console_scripts', 'pandoc-fignos')()
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/pandoc_fignos-0.16-py3.4.egg/pandoc_fignos.py", line 368, in main
    # Insert supporting TeX
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/pandoc_fignos-0.16-py3.4.egg/pandoc_fignos.py", line 366, in <lambda>

  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/pandocfilters-1.3.0-py3.4.egg/pandocfilters.py", line 34, in walk
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/pandocfilters-1.3.0-py3.4.egg/pandocfilters.py", line 25, in walk
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/pandoc_xnos-0.4.1-py3.4.egg/pandocxnos/core.py", line 474, in repair_refs
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/pandoc_xnos-0.4.1-py3.4.egg/pandocxnos/core.py", line 119, in wrapper
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/pandoc_xnos-0.4.1-py3.4.egg/pandocxnos/core.py", line 428, in _repair_refs
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/pandoc_xnos-0.4.1-py3.4.egg/pandocxnos/core.py", line 413, in _is_broken_ref
TypeError: can only concatenate list (not "str") to list
pandoc-1.17.2: Error running filter pandoc-fignos
Filter returned error status 1

xnos-number-by-section=False is broken for (X)HTML

The --metadata customisation xnos-number-by-section=False

-M xnos-number-by-section=False

is broken for (X)HTML. Numbering restarts with each section. This has been reported:

  • for fignos-number-by-section here,
  • for tablenos-number-by-section here, and
  • I have personally also experienced this bug for eqnos-number-by-section.

However, there is a pull request and a patch solving this issue waiting to be merged:

  • for tablenos-number-by-section here, and
  • for fignos-number-by-section here.

There is also a very cumbersome workaround that works for all xnos items when converting to (X)HTML.

Automatic numbering is an absolute key feature of the pandoc-xnos suite, but also a "deal-breaker" when not available. An expedient resolution of this bug is highly desirable.

Could not find executable pandoc-eqnos

Im installing into my docker container via pip like described:
RUN pip3 install pandoc-fignos pandoc-eqnos pandoc-tablenos \ pandoc-secnos --user
Leads to that error if i uses the filter like --filter pando-eqgnos

Error running filter pandoc-eqnos:
Could not find executable pandoc-eqnos

while installing into docker i get the following messages

The script pandoc-xnos is installed in '/root/.local/bin' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
  The script pandoc-fignos is installed in '/root/.local/bin' which is not on PATH.

any idea on how i can fix this ?

Theoremnos returns error when ran on Alpine Docker.

I have a setup with theoremnos running on my local computer without issues.

But I also use Github actions to run Pandoc in the same setup automatically whenever I update my repo containing the markdown files.

But the Github action returns an error when running theoremnos

Error running filter pandoc-theoremnos:
Error in $: Failed reading: not a valid json value

Sadly, this is all the information I got.

Three questions/issues

Greetings Tom.

I have three qustions/issues:

(1) Question.
I have

filters:
  - pandoc-xnos
  - citeproc

in my pandoc defaults file. Is this invocation sufficient for both pandoc-eqnos and pandoc-fignos?

(2) Question
I need to specify image width in figures so:

![Image caption](/path/to/image/image.png){ width=50% }

In such cases where does the {#fig:id} go? I have tried putting it separately and also within the curly braces, but with no luck so far. I think the figure reference must work with the image height or width specifier to be useful in practice.

(3) Issue/FeatureRequest
Given that citations are of the form [@citationref] for citations, could the suite of xnos follow the same [...] syntax rather than the braces {...} syntax as at present?

Thanks.

Feature: Remove redundant label

The label "Table:" is redundant:

Table: Caption. {#tbl:id}

By reversing the table reference identifier, this could be:

{#tbl:id} Caption.

This allows the author to change the label in a single location. Additionally, the same logic can be applied to equations, figures, and any other referenced element.

See also: jgm/pandoc#813 (comment)

Cannot determine pandoc version.

I get this error message when I try to convert a md using pandoc and pandoc-fignos.

Traceback (most recent call last):
File "/usr/local/bin/pandoc-fignos", line 7, in
from pandoc_fignos import main
File "/usr/local/lib/python2.7/site-packages/pandoc_fignos.py", line 66, in
PANDOCVERSION = pandocxnos.init(args.pandocversion)
File "/usr/local/lib/python2.7/site-packages/pandocxnos/core.py", line 186, in init
raise RuntimeError(textwrap.dedent(msg))
RuntimeError: Cannot determine pandoc version. Please file an issue at
https://github.com/tomduck/pandocfiltering/issues
Error running filter pandoc-fignos:
fd:12: hPutBuf: resource vanished (Broken pipe)

I saw this issue that seems related but was unable to use it to fix the problem.

Thanks!

`--filter pandoc-xnos` not working

Hi all,

I get an error when I try to pass the generic --filter pandoc-xnos, but individual packages work, such as --filter pandoc-secnos.

pandoc-xnos is indeed installed:

pip install pandoc-xnos
Requirement already satisfied: pandoc-xnos in ./.local/lib/python3.7/site-packages (2.3.0)
Requirement already satisfied: pandocfilters<2,>=1.4.2 in ./anaconda3/lib/python3.7/site-packages (from pandoc-xnos) (1.4.2)
Requirement already satisfied: psutil<6,>=4.1.0 in ./anaconda3/lib/python3.7/site-packages (from pandoc-xnos) (5.6.3)

But running the following fails:

pandoc -o 2019-11-18Referee-Report.pdf 2019-11-18Referee-Report.md --pdf-engine=xelatex --filter pandoc-xnos --filter pandoc-citeproc
Error running filter pandoc-xnos:
Could not find executable pandoc-xnos

While running this works:

pandoc -o 2019-11-18Referee-Report.pdf 2019-11-18Referee-Report.md --pdf-engine=xelatex --filter pandoc-secnos --filter pandoc-citeproc

pandoc-secnos: Wrote the following blocks to header-includes.  If you
use pandoc's --include-in-header option then you will need to manually
include these yourself.

    %% pandoc-secnos: required package
    \usepackage{cleveref}

Any idea what is going on?

Thanks!

Getting bad references despite following syntax

I'm working on a semester paper and will need to use cross references for different diagrams. Aside from pandoc-fignos, which works ok given Markdown's syntax for images, none of the other filters are working for me. When for example I use the pandoc-tablenos labels, I get:

pandoc-tablenos: Bad reference: @tbl:1.

pandoc-tablenos: Bad reference: @tbl:2.

The same happens if I use the other filters their other labels accordingly.

This is the test text I've been using:

This is a table

Table: Caption. {#tbl:id}


As Table @tbl:id indicates...

(I've tried the label both with and without curly brackets (i.e. {@TBL:id} and @TBL:id)

I would really like to solve this, as I'd use this filter within Rmarkdown and it used to work fine with images (and still does), however not with other kinds of captions (i.e. tables, equations or sections).

All I want is to number LaTeX tables using Markdown and a pandoc filter.

Feature request: API consistency

I have no clue whether fulfilling this request is even at all possible. Nevertheless, I would like to have this mentioned over here. Consider this:

  • ![Caption.](image.png){#fig:id} is allowed.

  • ![Caption.](image.png) {#fig:id} is not allowed.

  • Table: Caption. {#tbl:id} is allowed.

  • Table: Caption.{#tbl:id} is not allowed.

  • $$ y = mx + b $$ {#eq:id} is allowed.

  • $$ y = mx + b $${#eq:id} is equally allowed.

I take issue with the fact that the space preceding the curly braces (accolades) is required for tables, forbidden for images and optional for display equations. This kind of can get into one's clothes and break the flow when creating content.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.