Skip to content

Commit

Permalink
Refactor tags (#269)
Browse files Browse the repository at this point in the history
* Standardize disabling of Gollum tags per format
* Check tag format instead of trying to parse every tag as every kind of link
* More refactoring

* Fix errors

* Don't implicitly assume tag links are relative to the wiki root

* Fix image tags

* Fix include directive and tests

* Refactor

* Add regression test for File links without description

* New generic approach to skipping filters for specific formats

* Implement generic tag skipping in Markup instead of Filter class

* Add tests. Remove Markup#render_default
  • Loading branch information
dometto authored Apr 29, 2017
1 parent 420a85d commit 745136c
Show file tree
Hide file tree
Showing 11 changed files with 282 additions and 214 deletions.
4 changes: 2 additions & 2 deletions lib/gollum-lib/filter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,12 @@ def initialize(markup)
@map = {}
end

def extract(_d)
def extract(data)
raise RuntimeError,
"#{self.class} has not implemented ##extract!"
end

def process(_d)
def process(data)
raise RuntimeError,
"#{self.class} has not implemented ##process!"
end
Expand Down
2 changes: 0 additions & 2 deletions lib/gollum-lib/filter/code.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
class Gollum::Filter::Code < Gollum::Filter
def extract(data)
case @markup.format
when :txt
return data
when :asciidoc
data.gsub!(/^(\[source,([^\r\n]*)\]\n)?----\n(.+?)\n----$/m) do
cache_codeblock(Regexp.last_match[2], Regexp.last_match[3])
Expand Down
4 changes: 4 additions & 0 deletions lib/gollum-lib/filter/plain_text.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@

class Gollum::Filter::PlainText < Gollum::Filter

def do_process(_d)
skip? ? _d : process(_d)
end

def extract(data)
@markup.format == :txt ? "<pre>#{CGI.escapeHTML(data)}</pre>" : data
end
Expand Down
1 change: 0 additions & 1 deletion lib/gollum-lib/filter/plantuml.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ def self.configure
# Extract all sequence diagram blocks into the map and replace with
# placeholders.
def extract(data)
return data if @markup.format == :txt
data.gsub(/(@startuml\r?\n.+?\r?\n@enduml\r?$)/m) do
id = Digest::SHA1.hexdigest($1)
@map[id] = { :code => $1 }
Expand Down
1 change: 0 additions & 1 deletion lib/gollum-lib/filter/remote_code.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
#
class Gollum::Filter::RemoteCode < Gollum::Filter
def extract(data)
return data if @markup.format == :txt
data.gsub(/^[ \t]*``` ?([^:\n\r]+):((http)?[^`\n\r]+)```/) do
language = Regexp.last_match[1]
uri = Regexp.last_match[2]
Expand Down
Loading

0 comments on commit 745136c

Please sign in to comment.