quelques améliorations
This commit is contained in:
parent
d6ef507190
commit
5c52253646
|
@ -11,17 +11,21 @@ Si on souhaite convertir des pages du format Trac vers le format Markdown un pet
|
|||
body = STDIN.read
|
||||
|
||||
body.gsub!(/\{\{\{([^\n]+?)\}\}\}/, '`\1`')
|
||||
body.gsub!(/\{\{\{(.+?)\}\}\}/m){|m| m.each_line.map{|x| "\t#{x}".gsub(/[\{\}]{3}/,'')}.join}
|
||||
body.gsub!(/^\s*\*/, '*')
|
||||
body.gsub!(/(\S)\n\* /, '\1' "\n\n* ")
|
||||
body.gsub!(/^[ ]*\{\{\{/, '{{{')
|
||||
body.gsub!(/(\S)\n\{\{\{/, '\1' "\n\n{{{")
|
||||
body.gsub!(/\{\{\{(.+?)\}\}\}/m){|m| m.each_line.map{|x| "#{x}".gsub(/ *[\{\}]{3}/,"~~~")}.join}
|
||||
body.gsub!(/\=\=\=\=\=\s(.+?)\s\=\=\=\=\=/, '##### \1')
|
||||
body.gsub!(/\=\=\=\=\s(.+?)\s\=\=\=\=/, '#### \1')
|
||||
body.gsub!(/\=\=\=\s(.+?)\s\=\=\=/, '### \1')
|
||||
body.gsub!(/\=\=\s(.+?)\s\=\=/, '## \1')
|
||||
body.gsub!(/\=\s(.+?)\s\=/, '# \1')
|
||||
body.gsub!(/\[(https?[^\s\[\]]+)\s([^\[\]]+)\]/, '[\2](\1)')
|
||||
body.gsub!(/([^(])(https?[^\s\[\]]+)/, '\1<\2>')
|
||||
body.gsub!(/\!(([A-Z][a-z0-9]+){2,})/, '\1')
|
||||
body.gsub!(/'''(.+?)'''/, '*\1*')
|
||||
body.gsub!(/''(.+?)''/, '_\1_')
|
||||
body.gsub!(/^\s\*/, '*')
|
||||
body.gsub!(/^\s\d\./, '1.')
|
||||
|
||||
# custom add-on for pedantic satisfaction
|
||||
|
@ -30,10 +34,10 @@ body.gsub!(/ *(\.){3,}/, '…')
|
|||
STDOUT.write(body)
|
||||
~~~
|
||||
|
||||
Copiez simplement ce script là où vous le souhaitez, rendez-le exécutable puis
|
||||
Copiez simplement ce script là où vous le souhaitez, rendez-le exécutable puis :
|
||||
|
||||
~~~
|
||||
$ cat Page.trac | /path/to/trac_to_md > Page.md
|
||||
~~~{.bash}
|
||||
$ cat Page.trac | trac2md
|
||||
~~~
|
||||
|
||||
Quelques remarques :
|
||||
|
|
Loading…
Reference in New Issue