diff --git a/helpers/roam_helpers.rb b/helpers/roam_helpers.rb index f847c34..4b98816 100644 --- a/helpers/roam_helpers.rb +++ b/helpers/roam_helpers.rb @@ -28,10 +28,12 @@ def render_page_content(data, page = data) def render_block(block, page) content_tag(:div, class: block_class(block)) { render_markdown( - link_tokens( + link_refs( block["string"].to_s, page - ) + ).gsub(/(?[\w\s]+)::\s/) { |_match| + %(#{$1}: ) + } ).gsub(/\(\((?[^()]+)\)\)/) { uid = Regexp.last_match[:uid] if (ref = Hash(block["outbound_block_references"])[uid]) @@ -49,7 +51,7 @@ def render_block(block, page) } end - def link_tokens(string, page) + def link_refs(string, page) refs = Hash(page["outbound_page_references"]) return string unless refs.any? @@ -61,8 +63,6 @@ def link_tokens(string, page) string.gsub!(/(?<=\s)#(?!\[)#{Regexp.escape(title)}/, %(##{title})) end - string.gsub!(/(?[\w\s]+)::\s/) { |_match| %( ) } - string end