File: de-gfm

package info (click to toggle)
ruby-kramdown-rfc2629 1.7.34-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,044 kB
  • sloc: ruby: 3,938; makefile: 4
file content (48 lines) | stat: -rwxr-xr-x 924 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/usr/bin/env ruby -Ku

Encoding.default_external = "UTF-8" # wake up, smell the coffee

require 'kramdown'
require 'kramdown-parser-gfm'

options = ''
while /\A-([4bck]+)\z/ === ARGV[0]
  ARGV.shift
  options << $1
end

if /k/ === options              # kramdown
  MARKDOWN_BR = "\\\\\n"
end

if /c/ === options              # commonmark
  MARKDOWN_BR = "\\\n"
end

if /b/ === options              # universal HTML
  MARKDOWN_BR = "<br/>\n"
end

MARKDOWN_BR ||= "  \n"          # original Gruber

module Kramdown

  module Converter

    # Converts an element tree to the kramdown format.
    class Kramdown < Base

      # Argh
      def convert_br(_el, _opts)
        MARKDOWN_BR
      end
    end
  end
end

list_indent = 2
list_indent = 4 if /4/ === options

doc = Kramdown::Document.new(ARGF.read, input: 'GFM', gfm_quirks: 'paragraph_end',
                             list_indent: list_indent)
puts doc.to_kramdown