polytexnic 0.9.10 → 1.0.beta1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.pull_requests/1403381407 +0 -0
- data/lib/polytexnic/postprocessors/html.rb +14 -0
- data/lib/polytexnic/preprocessors/polytex.rb +9 -0
- data/lib/polytexnic/utils.rb +1 -0
- data/lib/polytexnic/version.rb +1 -1
- data/spec/markdown_to_polytex_spec.rb +14 -0
- data/spec/to_html/text_formatting_spec.rb +18 -3
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 751a1b5ecbbcd95df78fdc4651d8ec270990abbb
|
4
|
+
data.tar.gz: b57645b0af7b1d4c1a3067f0a2d8d954937348fc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 44ca3dac0ba83a5089e4066f82ec3330010c3e4020bfee990225282530d52c72cc972842ea63386fd2419b9025579014b2545bc2c1b262809c18c43de449a78f
|
7
|
+
data.tar.gz: 053ea3fcf06caac0461614417ca3b856fea2632dcf28491608dfe01445a745cf45e011a2488caeed12ddd38c42ea2a77449aeabbabf9cd4e68790560e5c11d44
|
File without changes
|
@@ -602,12 +602,26 @@ module Polytexnic
|
|
602
602
|
end
|
603
603
|
end
|
604
604
|
|
605
|
+
# Converts colored text to HTML.
|
605
606
|
def coloredtext(doc)
|
607
|
+
# Handle \coloredtext{red}{text}
|
606
608
|
doc.xpath('//coloredtext').each do |node|
|
607
609
|
node.name = 'span'
|
608
610
|
node['style'] = "color: #{node['color']}"
|
609
611
|
clean_node node, 'color'
|
610
612
|
end
|
613
|
+
|
614
|
+
# Handle \coloredtexthtml{ff0000}{text}
|
615
|
+
doc.xpath('//coloredtexthtml').each do |node|
|
616
|
+
node.name = 'span'
|
617
|
+
color = node['color']
|
618
|
+
# Catch common case of using lower-case hex.
|
619
|
+
if color =~ /[a-f]/
|
620
|
+
raise "RGB hex color must be upper-case (for LaTeX's sake)"
|
621
|
+
end
|
622
|
+
node['style'] = "color: ##{color}"
|
623
|
+
clean_node node, 'color'
|
624
|
+
end
|
611
625
|
end
|
612
626
|
|
613
627
|
# Converts filesystem path (\filepath) to the proper tag.
|
@@ -89,6 +89,7 @@ module Polytexnic
|
|
89
89
|
puts cleaned_markdown if debug?
|
90
90
|
cleaned_markdown.tap do |markdown|
|
91
91
|
convert_code_inclusion(markdown)
|
92
|
+
expand_input(markdown)
|
92
93
|
cache_latex_literal(markdown)
|
93
94
|
cache_raw_latex(markdown)
|
94
95
|
cache_image_locations(markdown)
|
@@ -187,6 +188,14 @@ module Polytexnic
|
|
187
188
|
end
|
188
189
|
end
|
189
190
|
|
191
|
+
# Expands '\input' command by processing & inserting the target source.
|
192
|
+
def expand_input(text)
|
193
|
+
text.gsub!(/^[ \t]*\\input\{(.*?)\}[ \t]*$/) do
|
194
|
+
source = File.read("#{$1}.md")
|
195
|
+
Polytexnic::Pipeline.new(source, source: :markdown).polytex
|
196
|
+
end
|
197
|
+
end
|
198
|
+
|
190
199
|
# Restores raw code from the cache.
|
191
200
|
def restore_hashed_content(text)
|
192
201
|
$cache.each do |key, value|
|
data/lib/polytexnic/utils.rb
CHANGED
@@ -113,6 +113,7 @@ module Polytexnic
|
|
113
113
|
\newcommand{\sout}[1]{\xmlelt{sout}{#1}}
|
114
114
|
\newcommand{\kode}[1]{\xmlelt{kode}{#1}}
|
115
115
|
\newcommand{\coloredtext}[2]{\xmlelt{coloredtext}{\AddAttToCurrent{color}{#1}#2}}
|
116
|
+
\newcommand{\coloredtexthtml}[2]{\xmlelt{coloredtexthtml}{\AddAttToCurrent{color}{#1}#2}}
|
116
117
|
\newcommand{\filepath}[1]{\xmlelt{filepath}{#1}}
|
117
118
|
\newcommand{\image}[1]{\xmlelt{image}{#1}}
|
118
119
|
\newcommand{\imagebox}[1]{\xmlelt{imagebox}{#1}}
|
data/lib/polytexnic/version.rb
CHANGED
@@ -528,5 +528,19 @@ def hello; puts 'hello'; end
|
|
528
528
|
end
|
529
529
|
end
|
530
530
|
end
|
531
|
+
|
532
|
+
describe '\input command' do
|
533
|
+
let(:external_file) { 'foo.md' }
|
534
|
+
before { File.write(external_file, input) }
|
535
|
+
after { File.unlink(external_file) }
|
536
|
+
|
537
|
+
let(:input) { 'lorem *ipsum* dolor sit amet' }
|
538
|
+
let(:output) do
|
539
|
+
Polytexnic::Pipeline.new(input, source: :markdown).polytex
|
540
|
+
end
|
541
|
+
let(:source) { "# Foo\n\n \\input{foo} " }
|
542
|
+
|
543
|
+
it { should include output }
|
544
|
+
end
|
531
545
|
end
|
532
546
|
end
|
@@ -47,9 +47,24 @@ describe 'Polytexnic::Pipeline#to_html' do
|
|
47
47
|
it { should resemble '<code>function_name</code>' }
|
48
48
|
end
|
49
49
|
|
50
|
-
|
51
|
-
|
52
|
-
|
50
|
+
context "coloredtext" do
|
51
|
+
describe "coloredtext command" do
|
52
|
+
let(:polytex) { '\coloredtext{red}{text}' }
|
53
|
+
it { should resemble '<span style="color: red">text</span>' }
|
54
|
+
end
|
55
|
+
|
56
|
+
context "coloredtexthtml command" do
|
57
|
+
describe "with a lower-case hex color" do
|
58
|
+
let(:polytex) { '\coloredtexthtml{ff0000}{text}' }
|
59
|
+
it "should raise an error" do
|
60
|
+
expect { processed_text }.to raise_error
|
61
|
+
end
|
62
|
+
end
|
63
|
+
describe "with an upper-case hex color" do
|
64
|
+
let(:polytex) { '\coloredtexthtml{FF0000}{text}' }
|
65
|
+
it { should resemble '<span style="color: #FF0000">text</span>' }
|
66
|
+
end
|
67
|
+
end
|
53
68
|
end
|
54
69
|
end
|
55
70
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: polytexnic
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.beta1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Hartl
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-06-
|
12
|
+
date: 2014-06-23 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: nokogiri
|
@@ -205,6 +205,7 @@ files:
|
|
205
205
|
- .pull_requests/1388802190
|
206
206
|
- .pull_requests/1389652617
|
207
207
|
- .pull_requests/1395697424
|
208
|
+
- .pull_requests/1403381407
|
208
209
|
- .rspec
|
209
210
|
- Gemfile
|
210
211
|
- Guardfile
|
@@ -283,9 +284,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
283
284
|
version: '0'
|
284
285
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
285
286
|
requirements:
|
286
|
-
- - '
|
287
|
+
- - '>'
|
287
288
|
- !ruby/object:Gem::Version
|
288
|
-
version:
|
289
|
+
version: 1.3.1
|
289
290
|
requirements: []
|
290
291
|
rubyforge_project:
|
291
292
|
rubygems_version: 2.0.14
|