Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Preserving code and table format pandoc markdown to pandoc markdown #5171

Closed
lamyergeier opened this issue Dec 22, 2018 · 1 comment
Closed

Comments

@lamyergeier
Copy link

lamyergeier commented Dec 22, 2018

Motivation

  • To convert all inline link to reference link while preserving other elements of markdown format, that I follow:
    • atx headers,
    • pipe style table,
    • backtick block code with name of language (without curly braces),
    • content never wrapped

Preface

Input Pandoc Markdown - Data.md

# Data

Table: Web frameworks

| Langauage                                                                                            | Framework                                                                                                                          |
| ---------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------- |
| [C++](https://en.wikipedia.org/wiki/C%2B%2B "C++")                                                   | [CppCMS](https://en.wikipedia.org/wiki/CppCMS "CppCMS"), [Wt](<https://en.wikipedia.org/wiki/Wt_(web_toolkit)> "Wt (web toolkit)") |
| [CLI](https://en.wikipedia.org/wiki/Common_Language_Infrastructure "Common Language Infrastructure") | [ASP.NET](https://en.wikipedia.org/wiki/ASP.NET "ASP.NET") , [Core](https://en.wikipedia.org/wiki/ASP.NET_Core "ASP.NET Core"),    |

```c
int a = 5;
```

- Input file `html`:

  ```bash
  pandoc -f html -t markdown http://www.fsf.org
  ```

  - Another

    ```
    pandoc -f html -t markdown http://www.fsf.org
    ```

---

Conversion Script

PandocExtension="-f markdown+table_captions-multiline_tables-simple_tables-grid_tables+pipe_tables-fenced_code_blocks-fenced_code_attributes+backtick_code_blocks"
PandocOption="-s --wrap=none --atx-headers  --reference-links --tab-stop 2"
pandoc ${PandocOption} ${PandocExtension} "./Data.md" -o "./Data.new.md"

Output Pandoc Markdown - Data.new.md

# Data

  Langauage   Framework
  ----------- ---------------------
  [C++]       [CppCMS], [Wt]
  [CLI]       [ASP.NET] , [Core],

  : Web frameworks

``` {.c}
int a = 5;
```

- Input file `html`:

  ``` {.bash}
  pandoc -f html -t markdown http://www.fsf.org
  ```

  - Another

      pandoc -f html -t markdown http://www.fsf.org

----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

  [C++]: https://en.wikipedia.org/wiki/C%2B%2B "C++"
  [CppCMS]: https://en.wikipedia.org/wiki/CppCMS "CppCMS"
  [Wt]: https://en.wikipedia.org/wiki/Wt_(web_toolkit) "Wt (web toolkit)"
  [CLI]: https://en.wikipedia.org/wiki/Common_Language_Infrastructure "Common Language Infrastructure"
  [ASP.NET]: https://en.wikipedia.org/wiki/ASP.NET "ASP.NET"
  [Core]: https://en.wikipedia.org/wiki/ASP.NET_Core "ASP.NET Core"

Expected Outcome:

# Data

Table: Web frameworks

| Langauage | Framework           |
| --------- | ------------------- |
| [C++]     | [CppCMS], [Wt]      |
| [CLI]     | [ASP.NET] , [Core], |

```c
int a = 5;
```

- Input file `html`:

  ```bash
  pandoc -f html -t markdown http://www.fsf.org
  ```

  - Another

    ```
    pandoc -f html -t markdown http://www.fsf.org
    ```


------------------------------------------------------------------------

  [C++]: https://en.wikipedia.org/wiki/C%2B%2B "C++"
  [CppCMS]: https://en.wikipedia.org/wiki/CppCMS "CppCMS"
  [Wt]: https://en.wikipedia.org/wiki/Wt_(web_toolkit) "Wt (web toolkit)"
  [CLI]: https://en.wikipedia.org/wiki/Common_Language_Infrastructure "Common Language Infrastructure"
  [ASP.NET]: https://en.wikipedia.org/wiki/ASP.NET "ASP.NET"
  [Core]: https://en.wikipedia.org/wiki/ASP.NET_Core "ASP.NET Core"

Issue

  1. How can I preserve the block code format (i.e. c instead of {.c}) while I have disabled fenced_code_attributes?
  2. How can I prevents backticks of fenced code from vanishing?
  3. How can I make sure that the table format is of pipe style as output?

Reference

  • Pandoc - Pandoc User’s Guide#
    • If the fenced_code_attributes extension is disabled, but input contains class attribute(s) for the code block, the first class attribute will be printed after the opening fence as a bare word.
@mb21
Copy link
Collaborator

mb21 commented Dec 23, 2018

That's actually three separate things you're asking. Please use the pandoc-discuss mailing list for questions like this in the future.

What you want is to change the output of pandoc, so you should change the extensions on the output format (-t markdown), not the input format (-f markdown...).

  1. use -t markdown-fenced_code_attributes
  2. not sure what you mean.
  3. To get pipe-tables with your input, simply use -t markdown-simple_tables

@mb21 mb21 closed this as completed Dec 23, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants