diff --git a/config.ru b/config.ru index 6bc7a3b..4f427e6 100644 --- a/config.ru +++ b/config.ru @@ -5,8 +5,8 @@ SERVE_DIR="/Users/madeline/Code/gemini-bridge-rack/gemini" class SkeksisApp def call(env) status = 200 - #headers = { "Content-Type" => "text/html" } - headers = {} + headers = { "content-type" => "text/html" } + #headers = {} body = resolve_path(SERVE_DIR + env['PATH_INFO']) [status, headers, body] @@ -18,8 +18,7 @@ class SkeksisApp elsif File.exist?(path) file = File.open(path, 'r') data = file.readlines - Skeksis::Parser.parse(data) - data + [Skeksis.htmlize(data)] else # path is invalid return nil end diff --git a/lib/skeksis.rb b/lib/skeksis.rb index abb9265..8f7b561 100644 --- a/lib/skeksis.rb +++ b/lib/skeksis.rb @@ -2,8 +2,15 @@ require_relative "skeksis/version" require_relative "skeksis/parser" +require_relative "skeksis/htmlize" module Skeksis class Error < StandardError; end # Your code goes here... + extend self + + def htmlize(data) + puts Skeksis::Parser.parse(data).htmlize + Skeksis::Parser.parse(data).htmlize + end end diff --git a/lib/skeksis/htmlize.rb b/lib/skeksis/htmlize.rb new file mode 100644 index 0000000..9fc981f --- /dev/null +++ b/lib/skeksis/htmlize.rb @@ -0,0 +1,60 @@ +module Skeksis + class IR + Header = <<~HTML + +
+#{text}" + when :uri + uri = entry[:uri] + text = entry[:text] + "#{text}" + when :verbatim + "
" + entry[:content].join("\n") + "" + when :text + "
#{text}
" + end + end + + html + end + end +end diff --git a/lib/skeksis/parser.rb b/lib/skeksis/parser.rb index ffef653..f6cb562 100644 --- a/lib/skeksis/parser.rb +++ b/lib/skeksis/parser.rb @@ -1,6 +1,16 @@ # Code adapted from MIT-licensed gemini-rb project # parser.rb hosted at # https://github.com/genenetwork/gemini-rb/blob/main/lib/gemini-rb/parser.rb +# +# Internal Representation types +# :blank +# :header +# :list +# :quote +# :uri +# :verbatim +# :text +# module Skeksis class IR < Array @@ -49,7 +59,7 @@ module Skeksis extend self def parse(input) - puts("##### PARSING STARTED #####") + #puts("##### PARSING STARTED #####") list = IR.new @@ -78,9 +88,11 @@ module Skeksis end list.strip_markers! - puts list + #puts list #puts strip_markers(list) - puts("##### PARSING FINISHED #####") + #puts("##### PARSING FINISHED #####") + + list end private