Преобразование кодовых блоков из asciidoc в уценку

Я пытаюсь преобразовать некоторые документы из формата asciidoc в Markdown. Поскольку pandoc не может сделать это сам по себе, я также использую asciidoctor для преобразования в промежуточный файл docbook:

asciidoctor -v -a leveloffset=+1 -d book -b docbook -s test.adoc -o test.xml
pandoc --highlight-style=pygments -f docbook --atx-headers -t markdown_strict test.xml -o test.Md

Кажется, что блоки кода не преобразованы должным образом. Они в порядке в docbook, но при преобразовании в Md у меня просто есть общий блок в блочных кавычках без подсветки синтаксиса. Вот пример.

Оригинальный блок asciidoc:

[source,c++]
....
#include <stdio.h>

int main(void)
{
    // Declaring one integer variable named a
    int a;

    // Declaring two at once: b and c
    int b, c;

    a = 1;
    b = 2;
    c = 3;

    // print out the values of our variables
    printf("a is %d, b is %d, and c is %d.\n", a, b, c);

    return a + b + c;
}
....

Блок докбука:

<programlisting language="c++" linenumbering="unnumbered">#include &lt;stdio.h&gt;

int main(void)
{
    // Declaring one integer variable named a
    int a;

    // Declaring two at once: b and c
    int b, c;

    a = 1;
    b = 2;
    c = 3;

    // print out the values of our variables
    printf("a is %d, b is %d, and c is %d.\n", a, b, c);

    return a + b + c;
}</programlisting>

Markdown у меня есть (просто с отступом)

#include <stdio.h>

int main(void)
{
    // Declaring one integer variable named a
    int a;

    // Declaring two at once: b and c
    int b, c;

    a = 1;
    b = 2;
    c = 3;

    // print out the values of our variables
    printf("a is %d, b is %d, and c is %d.\n", a, b, c);

    return a + b + c;
}

Ожидаемая уценка:

```c++
#include <stdio.h>

int main(void)
{
    // Declaring one integer variable named a
    int a;

    // Declaring two at once: b and c
    int b, c;

    a = 1;
    b = 2;
    c = 3;

    // print out the values of our variables
    printf("a is %d, b is %d, and c is %d.\n", a, b, c);

    return a + b + c;
}
```

Я использую пандок 2.9.2.1

Есть ли какие-то опции или настройки, которые я могу использовать для настройки вывода?


person Gabriele B    schedule 12.05.2020    source источник
comment
вам нужно будет опубликовать пример ввода docbook и ожидаемого/фактического вывода уценки. также убедитесь, что вы используете новейшую версию pandoc...   -  person mb21    schedule 13.05.2020


Ответы (1)


Проблема была в markdown_strict. Использование другого варианта уценки и расширения pandoc backtick_code_blocks решит проблему, т.е.:

pandoc --highlight-style=pygments -f docbook -t markdown-backtick_code_blocks test.xml -o test.Md
person Gabriele B    schedule 13.05.2020