Sha256: 8ca50a238bf79e6f6e6bc14817acc86f1282c7a056c461c6d6d337124e102915

Contents?: true

Size: 1.31 KB

Versions: 2

Compression:

Stored size: 1.31 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             ⟩
        textasciicircum    ^
        textbackslash      \\
        textasciitilde     ~
      }].freeze

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

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

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
latex-decode-0.1.1-java lib/latex/decode/punctuation.rb
latex-decode-0.1.1 lib/latex/decode/punctuation.rb