# frozen_string_literal: true #========================== # rsyntaxtree.rb #========================== # # Facade of rsyntaxtree library. When loaded by a driver script, it does all # the necessary 'require' to use the library. # Copyright (c) 2007-2023 Yoichiro Hasebe FONT_DIR = File.expand_path(File.join(__dir__, "/../fonts")) ETYPE_NODE = 1 ETYPE_LEAF = 2 SUBSCRIPT_CONST = 0.7 FONT_SCALING = 2 WHITESPACE_BLOCK = "■" class RSTError < StandardError def initialize(msg = "Error: something unexpected occurred") msg.gsub!(WHITESPACE_BLOCK, "<>") super msg end end require_relative 'rsyntaxtree/utils' require_relative 'rsyntaxtree/element' require_relative 'rsyntaxtree/elementlist' require_relative 'rsyntaxtree/svg_graph' require_relative 'rsyntaxtree/version' require_relative 'rsyntaxtree/string_parser' require 'cgi' require 'rsvg2' require 'rmagick' module RSyntaxTree class RSGenerator def initialize(params = {}) new_params = {} fontset = {} params.each do |keystr, value| key = keystr.to_sym case key when :data data = value data = data.gsub('-AMP-', '&') .gsub('-PERCENT-', "%") .gsub('-PRIME-', "'") .gsub('-SCOLON-', ';') .gsub('-OABRACKET-', '<') .gsub('-CABRACKET-', '>') .gsub('¥¥', '\¥') .gsub(/(?