diff --git a/examples/full.gmi b/examples/full.gmi index bbb49e3..05ca44a 100644 --- a/examples/full.gmi +++ b/examples/full.gmi @@ -1,7 +1,3 @@ -Gemtext prolofue - - - Annotation paragraph text @@ -33,10 +29,6 @@ Chapter 2 paragraph text -Gemtext epilogue - - - ## Related articles => ./foo-bar 1) 2024-09-12 Foo Bar diff --git a/examples/full.html b/examples/full.html index 94c2bf4..2e6dbed 100644 --- a/examples/full.html +++ b/examples/full.html @@ -1,6 +1,3 @@ -
-HTTP prologue -

@@ -79,8 +76,7 @@ Chapter 2 paragraph text

-HTTP epilogue -
+

Related articles

    @@ -101,3 +97,4 @@ September 12, 2024 (web.archive.org)
+
diff --git a/examples/full.repub b/examples/full.repub index a91e0a2..b2ca580 100644 --- a/examples/full.repub +++ b/examples/full.repub @@ -1,8 +1,3 @@ -article.prologue do |custom| - custom.for :html, 'HTTP prologue' - custom.for :gemtext, 'Gemtext prolofue' -end - article.annotation do |annotation| annotation.paragraph do |paragraph| paragraph.text 'Annotation paragraph text' @@ -54,11 +49,6 @@ end -article.epilogue do |custom| - custom.for :html, 'HTTP epilogue' - custom.for :gemtext, 'Gemtext epilogue' -end - article.footnotes_category 'Related articles' do |category| category.footnote( category: :self, diff --git a/lib/repubmark.rb b/lib/repubmark.rb index 314f721..8f3e242 100644 --- a/lib/repubmark.rb +++ b/lib/repubmark.rb @@ -21,7 +21,6 @@ require_relative 'repubmark/elems/article' # Always inside Article require_relative 'repubmark/elems/annotation' -require_relative 'repubmark/elems/custom_logue' require_relative 'repubmark/elems/footnotes_category' # Always inside Article, Chapter require_relative 'repubmark/elems/chapter' diff --git a/lib/repubmark/elems/article.rb b/lib/repubmark/elems/article.rb index 1069a6c..8041dce 100644 --- a/lib/repubmark/elems/article.rb +++ b/lib/repubmark/elems/article.rb @@ -29,10 +29,8 @@ module Repubmark def to_html [ - @prologue&.to_html, @annotation&.to_html, @chapter&.to_html, - @epilogue&.to_html, @footnotes_categories.any? ? "
\n
\n" : nil, *@footnotes_categories.map(&:to_html), @footnotes_categories.any? ? "
\n" : nil, @@ -41,10 +39,8 @@ module Repubmark def to_gemtext [ - @prologue&.to_gemtext, @annotation&.to_gemtext, @chapter&.to_gemtext, - @epilogue&.to_gemtext, *@footnotes_categories.map(&:to_gemtext), ].compact.join("\n\n\n").freeze end @@ -53,21 +49,9 @@ module Repubmark # Builder methods # ################### - def prologue - raise 'Prologue already exists' if @prologue - raise 'Prologue after annotation' if @annotation - raise 'Prologue after chapters' if @chapters - raise 'Prologue after epilogue' if @epilogue - - @prologue = CustomLogue.new self - yield @prologue - nil - end - def annotation raise 'Annotation already exists' if @annotation raise 'Annotation after chapters' if @chapter - raise 'Annotation after epilogue' if @epilogue @annotation = Annotation.new self yield @annotation @@ -80,8 +64,6 @@ module Repubmark end def method_missing(method_name, ...) - raise 'Chapters after epilogue' if @epilogue - chapter = @chapter || Chapter.new(self) if chapter.respond_to? method_name @chapter = chapter @@ -91,14 +73,6 @@ module Repubmark end end - def epilogue - raise 'Epilogue already exists' if @epilogue - - @epilogue = CustomLogue.new self - yield @epilogue - nil - end - def footnotes_category(name) footnotes_category = FootnotesCategory.new self, name @footnotes_categories << footnotes_category diff --git a/lib/repubmark/elems/custom_logue.rb b/lib/repubmark/elems/custom_logue.rb deleted file mode 100644 index a3bd396..0000000 --- a/lib/repubmark/elems/custom_logue.rb +++ /dev/null @@ -1,40 +0,0 @@ -# frozen_string_literal: true - -module Repubmark - module Elems - class CustomLogue < Base - parents :Article - - def initialize(parent) - super parent - @for = {} - end - - ################# - # Basic methods # - ################# - - def to_html - "
\n#{@for[:html].strip}\n
\n".freeze if @for[:html] - end - - def to_gemtext - "#{@for[:gemtext].strip}\n".freeze if @for[:gemtext] - end - - ################### - # Builder methods # - ################### - - def for(format, str) - raise 'Invalid format' unless FORMATS.include? format - raise 'Format already configured' if @for.key? format - - str = String(str).strip.freeze - return if str.empty? - - @for[format] = str - end - end - end -end