lib/rabbit/parser/rd/ext/block-verbatim.rb in rabbit-3.0.1 vs lib/rabbit/parser/rd/ext/block-verbatim.rb in rabbit-3.0.2
- old
+ new
@@ -1,6 +1,6 @@
-# Copyright (C) 2004-2021 Kouhei Sutou <kou@cozmixng.org>
+# Copyright (C) 2004-2022 Sutou Kouhei <kou@cozmixng.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
@@ -20,18 +20,18 @@
require "rabbit/utils"
require "rabbit/parser/rd/rt/rt2rabbit-lib"
require "rabbit/parser/rd/ext/base"
require "rabbit/parser/rd/ext/image"
require "rabbit/parser/rd/ext/video"
-require "rabbit/parser/ext/enscript"
-require "rabbit/parser/ext/tex"
require "rabbit/parser/ext/aafigure"
require "rabbit/parser/ext/blockdiag"
require "rabbit/parser/ext/charty"
require "rabbit/parser/ext/coderay"
require "rabbit/parser/ext/emacs"
+require "rabbit/parser/ext/enscript"
require "rabbit/parser/ext/rouge"
+require "rabbit/parser/ext/tex"
module Rabbit
module Parser
class RD
module Ext
@@ -53,30 +53,11 @@
def ext_block_verb_img(label, source, content, visitor)
return nil unless /\A(?:image|img)\z/i =~ label
src, prop = parse_source(source)
return nil if prop["src"].nil?
-
- if prop["align"] == "right"
- body = visitor.current_body
- if body["background-image"]
- raise ParseError,
- _("multiple 'align = right' isn't supported.")
- end
- prop.each do |name, value|
- name = name.gsub(/_/, "-")
- if name == "src"
- property_name = "background-image"
- else
- property_name = "background-image-#{name}"
- end
- body[property_name] = value
- end
- :no_element
- else
- make_image(visitor, prop["src"], prop)
- end
+ make_image(visitor, prop["src"], prop, body: visitor.current_body)
end
def ext_block_verb_video(label, source, content, visitor)
return nil unless /\Avideo\z/i =~ label
src, prop = parse_source(source)
@@ -99,34 +80,34 @@
result || default_ext_block_verbatim(label, src, src, visitor)
end
def ext_block_verb_LaTeX(label, source, content, visitor)
return nil unless /\ALaTeX\z/i =~ label
- make_image_from_file(source, visitor) do |src_file_path, prop|
- Parser::Ext::TeX.make_image_by_LaTeX(src_file_path, prop, visitor)
+ make_image_from_file(source, visitor) do |src_file, prop|
+ Parser::Ext::TeX.make_image_by_LaTeX(src_file.path, prop, visitor)
end
end
def ext_block_verb_mimeTeX(label, source, content, visitor)
return nil unless /\AmimeTeX\z/i =~ label
- make_image_from_file(source, visitor) do |src_file_path, prop|
- Parser::Ext::TeX.make_image_by_mimeTeX(src_file_path, prop,
+ make_image_from_file(source, visitor) do |src_file, prop|
+ Parser::Ext::TeX.make_image_by_mimeTeX(src_file.path, prop,
visitor)
end
end
def ext_block_verb_aafigure(label, source, content, visitor)
return nil unless /\Aaafigure\z/i =~ label
- make_image_from_file(source, visitor) do |src_file_path, prop|
- Parser::Ext::AAFigure.make_image(src_file_path, prop, visitor)
+ make_image_from_file(source, visitor) do |src_file, prop|
+ Parser::Ext::AAFigure.make_image(src_file.path, prop, visitor)
end
end
def ext_block_verb_blockdiag(label, source, content, visitor)
return nil unless /\Ablockdiag\z/i =~ label
- make_image_from_file(source, visitor) do |src_file_path, prop|
- Parser::Ext::BlockDiag.make_image(src_file_path, prop, visitor)
+ make_image_from_file(source, visitor) do |src_file, prop|
+ Parser::Ext::BlockDiag.make_image(src_file.path, prop, visitor)
end
end
def ext_block_verb_coderay(label, source, content, visitor)
return nil unless /\Acoderay (\w+)\z/i =~ label
@@ -203,11 +184,20 @@
result || default_ext_block_verbatim(label, src, src, visitor)
end
def ext_block_verb_charty(label, source, content, visitor)
return nil unless /\Acharty\z/i =~ label
- make_image_from_file(source, visitor) do |src_file_path, prop|
- Parser::Ext::Charty.make_image(src_file_path, prop, visitor)
+ make_image_from_file(source, visitor) do |src_file, prop|
+ Parser::Ext::Charty.make_image(src_file.path, prop, visitor)
+ end
+ end
+
+ def ext_block_verb_mermaid(label, source, content, visitor)
+ return nil unless /\Amermaid\z/i =~ label
+ make_image_from_file(source,
+ visitor,
+ extension: ".mmd") do |src_file, prop|
+ src_file
end
end
end
end
end