Sha256: b70ba423fc8415b668a5706c4887ae047081fae2e56233982fa85f5c6c1a645b

Contents?: true

Size: 1.18 KB

Versions: 1

Compression:

Stored size: 1.18 KB

Contents

# -*- coding: utf-8 -*-

module LaTeX
  module Decode
    
    class Punctuation < Decoder
      
      @macros = Hash[*%W{
        textendash         –
        textemdash         —
        textquoteleft      ‘
        textquoteright     ’
        quotesinglbase     ‚
        textquotedblleft   “
        textquotedblright  ”
        quotedblbase       „
        dag                †
        ddag               ‡
        textbullet         •
        dots               …
        textperthousand    ‰
        textpertenthousand ‱
        guilsinglleft      ‹
        guilsinglright     ›
        textreferencemark  ※
        textinterrobang    ‽
        textoverline       ‾
        langle             ⟨
        rangle             ⟩
      }].freeze

      @symbols = Hash[*%w[
        -     -
        --    –
        ---   —
        ``    “
        ''    ”
      ]].freeze

      @map = @macros.merge(@symbols).freeze
      
      @patterns = [
        /\\(#{ @macros.keys.map { |k| Regexp.escape(k) }.compact.join('|') })(?:\{\}|\s+|\b)/ou,
        /(-+|``|'')/,
        /()\\([$%#_])(\{\})?/,
        /()\\(~)\{\}/
      ].freeze
      
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
latex-decode-0.0.5 lib/latex/decode/punctuation.rb