Я пытаюсь преобразовать разметку Pandoc в разметку wiki Confluence, я использую markdown2confluence сделать основную часть работы.
Это работает довольно хорошо, за исключением тех случаев, когда я говорю о CSS и FreeMarker, которые используют { & Амп; } в коде, пока Confluence использует {{ & Амп; }} отметить начало / конец блока кода. Поэтому мне нужно соответствовать шаблону, заключенному в {{...}},
Если бы я знал (больше) Ruby, я мог бы починить его там, но я парень из Unix старой школы, поэтому я подумал о awk или sed.
Итак, я дошел до:
sed 's/{{\([^}}]*\)}}/{{"\1"}}/g' tmp.wkd
который занимает:
First we need a way to select a state (or group of states) CSS uses what
is called a selector to choose which elements to apply to, we have been
using one up until now without noticing, it is the {{*}} at the beginning
of our CSS. This is a special selector that means select everything. So
the rule that follows it (the bit between {{{}} and {{}}} apply to every
polygon on the map. But CSS allows us to insert a filter instead by
using {{[...]}} instead of {{*}}.
и производит:
First we need a way to select a state (or group of states) CSS uses what
is called a selector to choose which elements to apply to, we have been
using one up until now without noticing, it is the {{"*"}} at the beginning
of our CSS. This is a special selector that means select everything. So
the rule that follows it (the bit between {{"{"}} and {{""}}} apply to every
polygon on the map. But CSS allows us to insert a filter instead by
using {{"[...]"}} instead of {{"*"}}.
Но то, что мне нужно, это:
First we need a way to select a state (or group of states) CSS uses what
is called a selector to choose which elements to apply to, we have been
using one up until now without noticing, it is the {{*}} at the beginning
of our CSS. This is a special selector that means select everything. So
the rule that follows it (the bit between {{\{}} and {{\}}} apply to every
polygon on the map. But CSS allows us to insert a filter instead by
using {{[...]}} instead of {{*}}.
Также необходимо обрабатывать {{${type.name}}} который должен стать {{$\{type.name\}}},
Есть две проблемы
- Мне нужно заменить
{с\{вместо использования кавычек, поэтому мне нужно изменить\1как-то. - Противный вид
{{}}}(который должен прийти{{\}}}не получается, независимо от того, как я пытаюсь закончить сопоставление с образцом.
\(