Skip to content

Commit

Permalink
EXPERIMENTAL add markdown to guidelines
Browse files Browse the repository at this point in the history
  • Loading branch information
xhero committed Sep 6, 2021
1 parent 71c59f0 commit 987fdd9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
9 changes: 5 additions & 4 deletions lib/editor_configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -425,13 +425,14 @@ def self.get_show_layout(model)

# Gets the html file name.
def self.get_help_fname(name, model = "Source")
model = (model == "Source") ? "" : "#{model.downcase}_"
model = "#{model.downcase}_"
# translated version?
fname = ConfigFilePath.get_marc_editor_profile_path("/help/#{RISM::MARC}/#{model}#{name}_#{I18n.locale.to_s}.html")
#ap fname
fname = ConfigFilePath.get_marc_editor_profile_path("/help/#{RISM::MARC}/#{I18n.locale.to_s}/#{model}#{name}.md")
ap fname
return fname if File.exist?("#{Rails.root}/public#{fname}")
# english?
fname = ConfigFilePath.get_marc_editor_profile_path("/help/#{RISM::MARC}/#{model}#{name}_en.html")
fname = ConfigFilePath.get_marc_editor_profile_path("/help/#{RISM::MARC}/en/#{model}#{name}.md")
ap fname
return fname if File.exist?("#{Rails.root}/public#{fname}")
# nope...
return ""
Expand Down
5 changes: 4 additions & 1 deletion lib/guidelines.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ def initialize(ymlfile, lang)
@sidebar = Array.new
@version = @tree[:version]

@markdown = Redcarpet::Markdown.new(Redcarpet::Render::HTML, extensions = {})

# numbering
@chapterNb = 1
@sectionNb = 1
Expand Down Expand Up @@ -84,7 +86,8 @@ def subsection ss
end

def cat helpfile
text = IO.read(ConfigFilePath.get_marc_editor_profile_path("#{Rails.root}/public/help/#{RISM::MARC}/#{helpfile}_#{@lang}.html")) rescue "HELP WILL FOLLOW"
md = IO.read(ConfigFilePath.get_marc_editor_profile_path("#{Rails.root}/public/help/#{RISM::MARC}/#{@lang}/#{helpfile}.md")) rescue "#{@lang}/#{helpfile} file missing in this language"
text = @markdown.render(md)
@output += text
end
end

0 comments on commit 987fdd9

Please sign in to comment.