Compare commits
	
		
			No commits in common. "393c757d65624e37087ed82e3f5ccab649123d6d" and "78ff370a4ed7dbdb86a3eb363e77725e3e3755be" have entirely different histories.
		
	
	
		
			393c757d65
			...
			78ff370a4e
		
	
		
					 7 changed files with 93 additions and 11 deletions
				
			
		| 
						 | 
					@ -1,3 +1,7 @@
 | 
				
			||||||
 | 
					Gemtext prolofue
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Annotation paragraph text
 | 
					Annotation paragraph text
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -29,6 +33,10 @@ Chapter 2 paragraph text
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Gemtext epilogue
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
## Related articles
 | 
					## Related articles
 | 
				
			||||||
 | 
					
 | 
				
			||||||
=> ./foo-bar 1) 2024-09-12 Foo Bar
 | 
					=> ./foo-bar 1) 2024-09-12 Foo Bar
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,3 +1,6 @@
 | 
				
			||||||
 | 
					<div>
 | 
				
			||||||
 | 
					HTTP prologue
 | 
				
			||||||
 | 
					</div>
 | 
				
			||||||
<div class="nice-annotation">
 | 
					<div class="nice-annotation">
 | 
				
			||||||
<p>
 | 
					<p>
 | 
				
			||||||
<span>
 | 
					<span>
 | 
				
			||||||
| 
						 | 
					@ -76,7 +79,8 @@ Chapter 2 paragraph text
 | 
				
			||||||
</span>
 | 
					</span>
 | 
				
			||||||
</p>
 | 
					</p>
 | 
				
			||||||
<div>
 | 
					<div>
 | 
				
			||||||
<hr/>
 | 
					HTTP epilogue
 | 
				
			||||||
 | 
					</div>
 | 
				
			||||||
<h2>Related articles</h2>
 | 
					<h2>Related articles</h2>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
<ol>
 | 
					<ol>
 | 
				
			||||||
| 
						 | 
					@ -97,4 +101,3 @@ September 12, 2024
 | 
				
			||||||
(<a href="https://web.archive.org/arch/example.com">web.archive.org</a>)
 | 
					(<a href="https://web.archive.org/arch/example.com">web.archive.org</a>)
 | 
				
			||||||
</li>
 | 
					</li>
 | 
				
			||||||
</ol>
 | 
					</ol>
 | 
				
			||||||
</div>
 | 
					 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,3 +1,8 @@
 | 
				
			||||||
 | 
					article.prologue do |custom|
 | 
				
			||||||
 | 
					  custom.for :html,    'HTTP prologue'
 | 
				
			||||||
 | 
					  custom.for :gemtext, 'Gemtext prolofue'
 | 
				
			||||||
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
article.annotation do |annotation|
 | 
					article.annotation do |annotation|
 | 
				
			||||||
  annotation.paragraph do |paragraph|
 | 
					  annotation.paragraph do |paragraph|
 | 
				
			||||||
    paragraph.text 'Annotation paragraph text'
 | 
					    paragraph.text 'Annotation paragraph text'
 | 
				
			||||||
| 
						 | 
					@ -49,6 +54,11 @@ end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					article.epilogue do |custom|
 | 
				
			||||||
 | 
					  custom.for :html,    'HTTP epilogue'
 | 
				
			||||||
 | 
					  custom.for :gemtext, 'Gemtext epilogue'
 | 
				
			||||||
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
article.footnotes_category 'Related articles' do |category|
 | 
					article.footnotes_category 'Related articles' do |category|
 | 
				
			||||||
  category.footnote(
 | 
					  category.footnote(
 | 
				
			||||||
    category: :self,
 | 
					    category: :self,
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -21,6 +21,7 @@ require_relative 'repubmark/elems/article'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Always inside Article
 | 
					# Always inside Article
 | 
				
			||||||
require_relative 'repubmark/elems/annotation'
 | 
					require_relative 'repubmark/elems/annotation'
 | 
				
			||||||
 | 
					require_relative 'repubmark/elems/custom_logue'
 | 
				
			||||||
require_relative 'repubmark/elems/footnotes_category'
 | 
					require_relative 'repubmark/elems/footnotes_category'
 | 
				
			||||||
# Always inside Article, Chapter
 | 
					# Always inside Article, Chapter
 | 
				
			||||||
require_relative 'repubmark/elems/chapter'
 | 
					require_relative 'repubmark/elems/chapter'
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -29,18 +29,20 @@ module Repubmark
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      def to_html
 | 
					      def to_html
 | 
				
			||||||
        [
 | 
					        [
 | 
				
			||||||
 | 
					          @prologue&.to_html,
 | 
				
			||||||
          @annotation&.to_html,
 | 
					          @annotation&.to_html,
 | 
				
			||||||
          @chapter&.to_html,
 | 
					          @chapter&.to_html,
 | 
				
			||||||
          @footnotes_categories.any? ? "<div>\n<hr/>\n" : nil,
 | 
					          @epilogue&.to_html,
 | 
				
			||||||
          *@footnotes_categories.map(&:to_html),
 | 
					          *@footnotes_categories.map(&:to_html),
 | 
				
			||||||
          @footnotes_categories.any? ? "</div>\n" : nil,
 | 
					 | 
				
			||||||
        ].compact.join.freeze
 | 
					        ].compact.join.freeze
 | 
				
			||||||
      end
 | 
					      end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      def to_gemtext
 | 
					      def to_gemtext
 | 
				
			||||||
        [
 | 
					        [
 | 
				
			||||||
 | 
					          @prologue&.to_gemtext,
 | 
				
			||||||
          @annotation&.to_gemtext,
 | 
					          @annotation&.to_gemtext,
 | 
				
			||||||
          @chapter&.to_gemtext,
 | 
					          @chapter&.to_gemtext,
 | 
				
			||||||
 | 
					          @epilogue&.to_gemtext,
 | 
				
			||||||
          *@footnotes_categories.map(&:to_gemtext),
 | 
					          *@footnotes_categories.map(&:to_gemtext),
 | 
				
			||||||
        ].compact.join("\n\n\n").freeze
 | 
					        ].compact.join("\n\n\n").freeze
 | 
				
			||||||
      end
 | 
					      end
 | 
				
			||||||
| 
						 | 
					@ -49,9 +51,21 @@ module Repubmark
 | 
				
			||||||
      # Builder methods #
 | 
					      # 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
 | 
					      def annotation
 | 
				
			||||||
        raise 'Annotation already exists' if @annotation
 | 
					        raise 'Annotation already exists' if @annotation
 | 
				
			||||||
        raise 'Annotation after chapters' if @chapter
 | 
					        raise 'Annotation after chapters' if @chapter
 | 
				
			||||||
 | 
					        raise 'Annotation after epilogue' if @epilogue
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        @annotation = Annotation.new self
 | 
					        @annotation = Annotation.new self
 | 
				
			||||||
        yield @annotation
 | 
					        yield @annotation
 | 
				
			||||||
| 
						 | 
					@ -64,6 +78,8 @@ module Repubmark
 | 
				
			||||||
      end
 | 
					      end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      def method_missing(method_name, ...)
 | 
					      def method_missing(method_name, ...)
 | 
				
			||||||
 | 
					        raise 'Chapters after epilogue' if @epilogue
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        chapter = @chapter || Chapter.new(self)
 | 
					        chapter = @chapter || Chapter.new(self)
 | 
				
			||||||
        if chapter.respond_to? method_name
 | 
					        if chapter.respond_to? method_name
 | 
				
			||||||
          @chapter = chapter
 | 
					          @chapter = chapter
 | 
				
			||||||
| 
						 | 
					@ -73,6 +89,14 @@ module Repubmark
 | 
				
			||||||
        end
 | 
					        end
 | 
				
			||||||
      end
 | 
					      end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      def epilogue
 | 
				
			||||||
 | 
					        raise 'Epilogue already exists' if @epilogue
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        @epilogue = CustomLogue.new self
 | 
				
			||||||
 | 
					        yield @epilogue
 | 
				
			||||||
 | 
					        nil
 | 
				
			||||||
 | 
					      end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      def footnotes_category(name)
 | 
					      def footnotes_category(name)
 | 
				
			||||||
        footnotes_category = FootnotesCategory.new self, name
 | 
					        footnotes_category = FootnotesCategory.new self, name
 | 
				
			||||||
        @footnotes_categories << footnotes_category
 | 
					        @footnotes_categories << footnotes_category
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										40
									
								
								lib/repubmark/elems/custom_logue.rb
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										40
									
								
								lib/repubmark/elems/custom_logue.rb
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1,40 @@
 | 
				
			||||||
 | 
					# 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
 | 
				
			||||||
 | 
					        "<div>\n#{@for[:html].strip}\n</div>\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
 | 
				
			||||||
| 
						 | 
					@ -39,15 +39,11 @@ module Repubmark
 | 
				
			||||||
              result += "</span>\n"
 | 
					              result += "</span>\n"
 | 
				
			||||||
            end
 | 
					            end
 | 
				
			||||||
          end
 | 
					          end
 | 
				
			||||||
          result += %(<a href="#{url}">#{text}</a>)
 | 
					          result += %(<a href="#{url}">#{text}</a>\n)
 | 
				
			||||||
        else
 | 
					        else
 | 
				
			||||||
          result += text
 | 
					          result += %(#{text}\n)
 | 
				
			||||||
        end
 | 
					 | 
				
			||||||
        if descr
 | 
					 | 
				
			||||||
          result += " — #{descr}\n"
 | 
					 | 
				
			||||||
        else
 | 
					 | 
				
			||||||
          result += "\n"
 | 
					 | 
				
			||||||
        end
 | 
					        end
 | 
				
			||||||
 | 
					        result += " — #{descr}\n" if descr
 | 
				
			||||||
        if alt_urls&.any?
 | 
					        if alt_urls&.any?
 | 
				
			||||||
          result += %[(#{
 | 
					          result += %[(#{
 | 
				
			||||||
            alt_urls.map do |alt_url|
 | 
					            alt_urls.map do |alt_url|
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue