mirror of https://github.com/freeCodeCamp/devdocs
Merge pull request #1548 from Cimbali/latex
commit
5916ee829c
File diff suppressed because one or more lines are too long
@ -0,0 +1,25 @@
|
||||
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]+)* /, '' }
|
||||
|
||||
css('pre').each do |node|
|
||||
node.delete 'class'
|
||||
node['data-language'] = 'latex'
|
||||
end
|
||||
|
||||
doc
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@ -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
|
After Width: | Height: | Size: 305 B |
After Width: | Height: | Size: 568 B |
@ -0,0 +1 @@
|
||||
Compiling \LaTeX with pdflatex https://www.tug.org/applications/pdftex/
|
Loading…
Reference in new issue