proper autolinks in html

This commit is contained in:
Yessiest 2025-03-07 23:49:11 +00:00
parent acf03f6b36
commit c31365115b
4 changed files with 12 additions and 10 deletions

View File

@ -1,4 +1,4 @@
#!/bin/ruby #!/usr/bin/env ruby
# frozen_string_literal: true # frozen_string_literal: true
require 'io/console/size' require 'io/console/size'
@ -116,8 +116,6 @@ class OptionNavigator
end end
end end
return unless $PROGRAM_NAME == __FILE__
options = { options = {
include: [], include: [],
nav: OptionNavigator.new nav: OptionNavigator.new
@ -162,7 +160,7 @@ renderer_opts["hsize"] ||= IO.console_size[1]
input = ARGV[0] == "-" ? $stdin.read : File.read(ARGV[0]) input = ARGV[0] == "-" ? $stdin.read : File.read(ARGV[0])
output = ARGV[1] == "-" ? $stdout : File.open(ARGV[1], "w") output = ARGV[1] == "-" ? $stdout : File.open(ARGV[1], "w")
doc = MMMD.parse(input) doc = MMMD.parse(input)
rclass = Renderers[options[:renderer] || "PlainTerm"] rclass = Renderers[options[:renderer] || "Plainterm"]
raise StandardError, "unknown renderer: #{options[:renderer]}" unless rclass raise StandardError, "unknown renderer: #{options[:renderer]}" unless rclass
renderer = rclass.call.new(doc, renderer_opts) renderer = rclass.call.new(doc, renderer_opts)

View File

@ -1209,7 +1209,9 @@ module PointBlank
end end
return '<', parts[1..] unless buffer.match?(/^<[\w\-_+]+:[^<>\s]+>$/) return '<', parts[1..] unless buffer.match?(/^<[\w\-_+]+:[^<>\s]+>$/)
[build([buffer[1..-2]]), parts[(cutoff + 1)..]] obj = build([buffer[1..-2]])
obj.properties[:uri] = buffer[1..-2]
[obj, parts[(cutoff + 1)..]]
end end
end end

View File

@ -98,6 +98,10 @@ module MMMD
}, },
"PointBlank::DOM::Text" => { "PointBlank::DOM::Text" => {
sanitize: true sanitize: true
},
"PointBlank::DOM::InlineAutolink" => {
tag: "a",
href: true
} }
}.freeze }.freeze
@ -311,14 +315,12 @@ module MMMD
def read_title(element) def read_title(element)
title = element.properties[:title] title = element.properties[:title]
title = MMMD::EntityUtils.encode_entities(title) title.inspect
title.dump
end end
def read_link(element) def read_link(element)
link = element.properties[:uri] link = element.properties[:uri]
link = MMMD::EntityUtils.encode_entities(link) link.inspect
link.dump
end end
def indent(text) def indent(text)

View File

@ -14,7 +14,7 @@ Gem::Specification.new do |spec|
spec.email = "yessiest@text.512mb.org" spec.email = "yessiest@text.512mb.org"
spec.homepage = "https://adastra7.net/git/Yessiest/rubymark" spec.homepage = "https://adastra7.net/git/Yessiest/rubymark"
spec.files = Dir["lib/**/*"] spec.files = Dir["lib/**/*"]
spec.bindir = Dir["bin/"] spec.bindir = Dir["bin"]
spec.executables << "mmmdpp" spec.executables << "mmmdpp"
spec.extra_rdoc_files = Dir["*.md"] spec.extra_rdoc_files = Dir["*.md"]
spec.required_ruby_version = ">= 3.0.0" spec.required_ruby_version = ">= 3.0.0"