History

Add LaTeX documentation from https://latexref.xyz

From https://ctan.org/pkg/latex2e-help-texinfo, the license is Public Domain.

Cimbali committed 6 years ago

Commit 776ec5a1 parent cce7c496 files · +87 −-2Browse files

Unified · Split

6 files
  1. lib/docs/filters/latex/clean_html.rb +20 −0
  2. lib/docs/filters/latex/entries.rb +46 −0
  3. lib/docs/scrapers/latex.rb +22 −0
  4. public/icons/docs/latex/16.png +0 −0
  5. public/icons/docs/latex/16@2x.png +0 −0
  6. public/icons/docs/latex/SOURCE +1 −0
lib/docs/filters/latex/clean_html.rb+20−0
@@ -0,0 +1,20 @@
1module Docs
2 class Latex
3 class CleanHtmlFilter < Filter
4 def call
5 css('hr, div.header, div.referenceinfo').remove
6 css('div.shortcontents, div.contents, h2.shortcontents-heading, h2.contents-heading, h1.settitle').remove if root_page?
7
8 css('span[id] + h1, span[id] + h2, span[id] + h3, span[id] + h4, span[id] + h5, span[id] + h6').each do |node|
9 id = node.previous['id']
10 node.previous.remove
11 node['id'] = id.sub(/-\d$/, '') if id
12 end
13
14 css('h1, h2, h3, h4').each { |node| node.content = node.content.sub /^[0-9A-Z]+(\.[0-9]+)* /, '' }
15
16 doc
17 end
18 end
19 end
20end
lib/docs/filters/latex/entries.rb+46−0
@@ -0,0 +1,46 @@
1module Docs
2 class Latex
3 class EntriesFilter < Docs::EntriesFilter
4
5 @@entries = Hash.new
6
7 def initialize(*)
8 super
9
10 return unless root_page?
11
12 css('.contents > ul > li').each do |node|
13 lev1 = node.at_css('> a:first-child').text.sub /^[0-9A-Z]+(\.[0-9]+)* /, ''
14 node.css('a').each do |link|
15 href = link['href'].split('#')[0].parameterize.downcase
16 @@entries[href] = lev1
17 end
18 end
19
20 end
21
22 def get_name
23 at_css('h1, h2, h3, h4, h5, h6').content.sub /^[0-9A-Z]+(\.[0-9]+)* /, ''
24 end
25
26 def get_type
27 begin
28 return @@entries[slug.downcase]
29 rescue
30 return "Missing type with slug #{slug}"
31 end
32 end
33
34 def include_default_entry?
35 true
36 end
37
38 def additional_entries
39 return []
40 end
41
42 private
43
44 end
45 end
46end
lib/docs/scrapers/latex.rb+22−0
@@ -0,0 +1,22 @@
1module Docs
2 class Latex < UrlScraper
3 self.name = 'LaTeX'
4 self.slug = 'latex'
5 self.type = 'simple'
6 self.links = {
7 home: 'https://ctan.org/pkg/latex2e-help-texinfo/'
8 }
9
10 self.base_url = 'http://latexref.xyz'
11
12 html_filters.push 'latex/entries', 'latex/clean_html'
13
14 options[:skip_patterns] = [/^\/dev\//, /\.(dvi|pdf)$/]
15
16 options[:attribution] = <<-HTML
17 &copy; 2007–2018 Karl Berry<br>
18 Public Domain Software
19 HTML
20
21 end
22end
public/icons/docs/latex/16.png+0−0

Binary file not shown.

public/icons/docs/latex/16@2x.png+0−0

Binary file not shown.

public/icons/docs/latex/SOURCE+1−0
@@ -0,0 +1 @@
1Compiling \LaTeX with pdflatex https://www.tug.org/applications/pdftex/