diff --git a/lib/docs/filters/latex/clean_html.rb b/lib/docs/filters/latex/clean_html.rb new file mode 100644 index 00000000..cc327b04 --- /dev/null +++ b/lib/docs/filters/latex/clean_html.rb @@ -0,0 +1,20 @@ +module Docs + class Latex + class CleanHtmlFilter < Filter + def call + css('hr, div.header, div.referenceinfo').remove + css('div.shortcontents, div.contents, h2.shortcontents-heading, h2.contents-heading, h1.settitle').remove if root_page? + + css('span[id] + h1, span[id] + h2, span[id] + h3, span[id] + h4, span[id] + h5, span[id] + h6').each do |node| + id = node.previous['id'] + node.previous.remove + node['id'] = id.sub(/-\d$/, '') if id + end + + css('h1, h2, h3, h4').each { |node| node.content = node.content.sub /^[0-9A-Z]+(\.[0-9]+)* /, '' } + + doc + end + end + end +end diff --git a/lib/docs/filters/latex/entries.rb b/lib/docs/filters/latex/entries.rb new file mode 100644 index 00000000..5270229b --- /dev/null +++ b/lib/docs/filters/latex/entries.rb @@ -0,0 +1,46 @@ +module Docs + class Latex + class EntriesFilter < Docs::EntriesFilter + + @@entries = Hash.new + + def initialize(*) + super + + return unless root_page? + + css('.contents > ul > li').each do |node| + lev1 = node.at_css('> a:first-child').text.sub /^[0-9A-Z]+(\.[0-9]+)* /, '' + node.css('a').each do |link| + href = link['href'].split('#')[0].parameterize.downcase + @@entries[href] = lev1 + end + end + + end + + def get_name + at_css('h1, h2, h3, h4, h5, h6').content.sub /^[0-9A-Z]+(\.[0-9]+)* /, '' + end + + def get_type + begin + return @@entries[slug.downcase] + rescue + return "Missing type with slug #{slug}" + end + end + + def include_default_entry? + true + end + + def additional_entries + return [] + end + + private + + end + end +end diff --git a/lib/docs/scrapers/latex.rb b/lib/docs/scrapers/latex.rb new file mode 100644 index 00000000..e603b72a --- /dev/null +++ b/lib/docs/scrapers/latex.rb @@ -0,0 +1,22 @@ +module Docs + class Latex < UrlScraper + self.name = 'LaTeX' + self.slug = 'latex' + self.type = 'simple' + self.links = { + home: 'https://ctan.org/pkg/latex2e-help-texinfo/' + } + + self.base_url = 'http://latexref.xyz' + + html_filters.push 'latex/entries', 'latex/clean_html' + + options[:skip_patterns] = [/^\/dev\//, /\.(dvi|pdf)$/] + + options[:attribution] = <<-HTML + © 2007–2018 Karl Berry
+ Public Domain Software + HTML + + end +end diff --git a/public/icons/docs/latex/16.png b/public/icons/docs/latex/16.png new file mode 100644 index 00000000..19a8a6a6 Binary files /dev/null and b/public/icons/docs/latex/16.png differ diff --git a/public/icons/docs/latex/16@2x.png b/public/icons/docs/latex/16@2x.png new file mode 100644 index 00000000..971833b2 Binary files /dev/null and b/public/icons/docs/latex/16@2x.png differ diff --git a/public/icons/docs/latex/SOURCE b/public/icons/docs/latex/SOURCE new file mode 100644 index 00000000..f7dad480 --- /dev/null +++ b/public/icons/docs/latex/SOURCE @@ -0,0 +1 @@ +Compiling \LaTeX with pdflatex https://www.tug.org/applications/pdftex/