reverse_markdown-1.4.0/ 0000755 0000041 0000041 00000000000 13605223630 015121 5 ustar www-data www-data reverse_markdown-1.4.0/.travis.yml 0000644 0000041 0000041 00000000436 13605223630 017235 0 ustar www-data www-data # before_install:
# - gem install bundler
rvm:
- 1.9.3
- 2.0.0
- 2.1.0
- 2.1.5
- 2.2.0
- 2.2.4
- 2.2.5
- 2.3.0
- 2.3.1
- 2.4.2
- 2.5.3
- 2.6.2
- jruby-9.2.8.0
script: "bundle exec rake spec"
notifications:
disabled: false
recipients:
- xijo@pm.me
reverse_markdown-1.4.0/.rspec 0000644 0000041 0000041 00000000010 13605223630 016225 0 ustar www-data www-data --color
reverse_markdown-1.4.0/README.md 0000644 0000041 0000041 00000010344 13605223630 016402 0 ustar www-data www-data # Summary
Transform html into markdown. Useful for example if you want to import html into your markdown based application.
[](https://travis-ci.org/xijo/reverse_markdown) [](http://badge.fury.io/rb/reverse_markdown) [](https://codeclimate.com/github/xijo/reverse_markdown) [](https://codeclimate.com/github/xijo/reverse_markdown)
## Changelog
See [Change Log](CHANGELOG.md)
## Requirements
1. [Nokogiri](http://nokogiri.org/)
2. Ruby 1.9.3 or higher
## Installation
Install the gem
```sh
[sudo] gem install reverse_markdown
```
or add it to your Gemfile
```ruby
gem 'reverse_markdown'
```
## Features
- Supports all the established html tags like `h1`, `h2`, `h3`, `h4`, `h5`, `h6`, `p`, `em`, `strong`, `i`, `b`, `blockquote`, `code`, `img`, `a`, `hr`, `li`, `ol`, `ul`, `table`, `tr`, `th`, `td`, `br`
- Module based - if you miss a tag, just add it
- Can deal with nested lists
- Inline and block code is supported
- Supports blockquote
# Usage
## Ruby
You can convert html content as string or Nokogiri document:
```ruby
input = 'feelings'
result = ReverseMarkdown.convert input
result.inspect # " **feelings** "
````
## Commandline
It's also possible to convert html files to markdown using the binary:
```sh
$ reverse_markdown file.html > file.md
$ cat file.html | reverse_markdown > file.md
````
## Configuration
The following options are available:
- `unknown_tags` (default `pass_through`) - how to handle unknown tags. Valid options are:
- `pass_through` - Include the unknown tag completely into the result
- `drop` - Drop the unknown tag and its content
- `bypass` - Ignore the unknown tag but try to convert its content
- `raise` - Raise an error to let you know
- `github_flavored` (default `false`) - use [github flavored markdown](https://help.github.com/articles/github-flavored-markdown) (yet only code blocks are supported)
- `tag_border` (default `' '`) - how to handle tag borders. valid options are:
- `' '` - Add whitespace if there is none at tag borders.
- `''` - Do not not add whitespace.
### As options
Just pass your chosen configuration options in after the input. The given options will last for this operation only.
```ruby
ReverseMarkdown.convert(input, unknown_tags: :raise, github_flavored: true)
```
### Preconfigure
Or configure it block style on a initializer level. These configurations will last for all conversions until they are set to something different.
```ruby
ReverseMarkdown.config do |config|
config.unknown_tags = :bypass
config.github_flavored = true
config.tag_border = ''
end
```
# Related stuff
- [Write custom converters](https://github.com/xijo/reverse_markdown/wiki/Write-your-own-converter) - Wiki entry about how to write your own converter
- [html_massage](https://github.com/harlantwood/html_massage) - A gem by Harlan T. Wood to convert regular sites into markdown using reverse_markdown
- [word-to-markdown](https://github.com/benbalter/word-to-markdown) - Convert word docs into markdown while using reverse_markdown, by Ben Balter
- [markdown syntax](http://daringfireball.net/projects/markdown) - The markdown syntax specification
- [github flavored markdown](https://help.github.com/articles/github-flavored-markdown) - Githubs extension to markdown
- [wmd-editor](http://wmd-editor.com) - Markdown flavored text editor
# Thanks
Thanks to all [contributors](https://github.com/xijo/reverse_markdown/graphs/contributors) and all other helpers:
- [Empact](https://github.com/Empact) Ben Woosley
- [harlantwood](https://github.com/harlantwood) Harlan T. Wood
- [aprescott](https://github.com/aprescott) Adam Prescott
- [danschultzer](https://github.com/danschultzer) Dan Schultzer
- [Benjamin-Dobell](https://github.com/Benjamin-Dobell) Benjamin Dobell
- [schkovich](https://github.com/schkovich) Goran Miskovic
- [craig-day](https://github.com/craig-day) Craig Day
- [grmartin](https://github.com/grmartin) Glenn R. Martin
- [willglynn](https://github.com/willglynn) Will Glynn
reverse_markdown-1.4.0/bin/ 0000755 0000041 0000041 00000000000 13605223630 015671 5 ustar www-data www-data reverse_markdown-1.4.0/bin/reverse_markdown 0000755 0000041 0000041 00000001130 13605223630 021167 0 ustar www-data www-data #!/usr/bin/env ruby
# Usage: reverse_markdown [FILE]...
# Usage: cat FILE | reverse_markdown
require 'reverse_markdown'
require 'optparse'
options = {}
OptionParser.new do |opts|
opts.banner = "Usage: reverse_markdown [options] some text Bird McHale Parish yes! yes! yes! This is an example inline link. This link has no title attribute. This is a normal paragraph: Here is an example of AppleScript: foo\nbar foo \r\n\r\n bar \n\nfoo bar foo bar\n\n foo\u00A0bar \u00A0 <foo> `foo_bar` `foo_bar __example__` `def foo *args` `def foo 2***3` Some text. Some more text. tags" do
xit { is_expected.to match /\n- I want to have a party at my house!\n/ }
end
context "list item containing multiple tags" do
xit { is_expected.to match /\n- li 1, p 1\n\n- li 1, p 2\n/ }
end
context 'it produces correct numbering' do
it { is_expected.to include "1. one" }
it { is_expected.to include " 1. one one" }
it { is_expected.to include " 2. one two" }
it { is_expected.to include "2. two" }
it { is_expected.to include " 1. two one" }
it { is_expected.to include " 1. two one one" }
it { is_expected.to include " 2. two one two" }
it { is_expected.to include " 2. two two" }
it { is_expected.to include "3. three" }
end
context "properly embeds a nested list between adjacent list items" do
it { is_expected.to match /\n- alpha\n/ }
it { is_expected.to match /\n- bravo/ }
it { is_expected.to match /\n - bravo alpha\n/ }
it { is_expected.to match /\n - bravo bravo/ }
it { is_expected.to match /\n - bravo bravo alpha/ }
it { is_expected.to match /\n- charlie\n/ }
it { is_expected.to match /\n- delta\n/ }
end
end
reverse_markdown-1.4.0/spec/components/html_fragment_spec.rb 0000644 0000041 0000041 00000000440 13605223630 024424 0 ustar www-data www-data require 'spec_helper'
describe ReverseMarkdown do
let(:input) { File.read('spec/assets/html_fragment.html') }
let(:document) { Nokogiri::HTML(input) }
subject { ReverseMarkdown.convert(input) }
it { is_expected.to eq("naked text 1\n\nparagraph text\n\nnaked text 2") }
end
reverse_markdown-1.4.0/spec/components/escapables_spec.rb 0000644 0000041 0000041 00000001251 13605223630 023700 0 ustar www-data www-data require 'spec_helper'
describe ReverseMarkdown do
let(:input) { File.read('spec/assets/escapables.html') }
let(:document) { Nokogiri::HTML(input) }
subject { ReverseMarkdown.convert(input) }
context "multiple asterisks" do
it { is_expected.to include ' \*\*two asterisks\*\* ' }
it { is_expected.to include ' \*\*\*three asterisks\*\*\* ' }
end
context "multiple underscores" do
it { is_expected.to include ' \_\_two underscores\_\_ ' }
it { is_expected.to include ' \_\_\_three underscores\_\_\_ ' }
end
context "underscores within words in code blocks" do
it { is_expected.to include ' var theoretical_max_infin = 1.0;' }
end
end
reverse_markdown-1.4.0/spec/components/anchors_spec.rb 0000644 0000041 0000041 00000003001 13605223630 023226 0 ustar www-data www-data require 'spec_helper'
describe ReverseMarkdown do
let(:input) { File.read('spec/assets/anchors.html') }
let(:document) { Nokogiri::HTML(input) }
subject { ReverseMarkdown.convert(input) }
it { is_expected.to include '[Foobar](http://foobar.com)' }
it { is_expected.to include '[Fubar](http://foobar.com "f\*\*\*\*\* up beyond all recognition")' }
it { is_expected.to include '[**Strong foobar**](http://strong.foobar.com)' }
it { is_expected.to include '  ' }
it { is_expected.to include '  ' }
it { is_expected.to include '  ' }
it { is_expected.to include 'no extra space before and after the anchor ([stripped](http://foobar.com)).'}
it { is_expected.to include 'after an ! [there](http://not.an.image.foobar.com) should be an extra space.'}
it { is_expected.to include 'with stripped elements inbetween: ! [there](http://still.not.an.image.foobar.com) should be an extra space.'}
context "links to ignore" do
it { is_expected.to include ' ignore anchor tags with no link text ' }
it { is_expected.to include ' not ignore [](foo.html) anchor tags with images' }
it { is_expected.to include ' pass through the text of [internal jumplinks](#content) without treating them as links ' }
it { is_expected.to include ' pass through the text of anchor tags with no href without treating them as links ' }
end
end
reverse_markdown-1.4.0/spec/components/from_the_wild_spec.rb 0000644 0000041 0000041 00000001022 13605223630 024414 0 ustar www-data www-data require 'spec_helper'
describe ReverseMarkdown do
let(:input) { File.read('spec/assets/from_the_wild.html') }
let(:document) { Nokogiri::HTML(input) }
subject { ReverseMarkdown.convert(input) }
it "should make sense of strong-crazy markup (as seen in the wild)" do
expect(subject).to include "**. \n \\*\\*\\* intentcast** : logo design \n **.**\n\n"
end
it "should not over escape * or _" do
expect(subject).to include '[ I\_AM\_HELPFUL](example.com/foo_bar)'
end
end
reverse_markdown-1.4.0/spec/assets/ 0000755 0000041 0000041 00000000000 13605223630 017355 5 ustar www-data www-data reverse_markdown-1.4.0/spec/assets/tables.html 0000644 0000041 0000041 00000002077 13605223630 021523 0 ustar www-data www-data
First quoted paragraph Second quoted paragraph paragraph text some text... a nested list with no whitespace: a nested list with lots of whitespace: I want to have a party at my house! li 1, p 1 li 1, p 2 li 2, p 1 a nested list between adjacent list items
Hallo em Text
strong
First quoted paragraph Second quoted paragraph
Paragraph with inline
. double em tags in p tag double strong tags in p tag First content
Second
content
Complex
blocks" do
roundtrip_should_preserve('
')
end
it "should preserve unordered lists" do
roundtrip_should_preserve("
")
end
it "should preserve ordered lists" do
roundtrip_should_preserve("
")
end
it "should preserve lists with paragraphs" do
roundtrip_should_preserve("
")
end
it "should preserve
tags" do
roundtrip_should_preserve("
")
end
it "should preserve tags" do
roundtrip_should_preserve("
tags" do
roundtrip_should_preserve("
\n we can! tags" do
roundtrip_should_preserve(%{


})
end
it "should preserve code blocks with embedded whitespace" do
roundtrip_should_preserve(%{
This is a code block.
})
end
end
reverse_markdown-1.4.0/spec/lib/ 0000755 0000041 0000041 00000000000 13605223630 016621 5 ustar www-data www-data reverse_markdown-1.4.0/spec/lib/reverse_markdown_spec.rb 0000644 0000041 0000041 00000002655 13605223630 023545 0 ustar www-data www-data require 'spec_helper'
describe ReverseMarkdown do
let(:input) { File.read('spec/assets/minimum.html') }
let(:document) { Nokogiri::HTML(input) }
it "parses nokogiri documents" do
expect { ReverseMarkdown.convert(document) }.not_to raise_error
end
it "parses nokogiri elements" do
expect { ReverseMarkdown.convert(document.root) }.not_to raise_error
end
it "parses string input" do
expect { ReverseMarkdown.convert(input) }.not_to raise_error
end
it "behaves in a sane way when root element is nil" do
expect(ReverseMarkdown.convert(nil)).to eq ''
end
describe '#config' do
it 'stores a given configuration option' do
ReverseMarkdown.config.github_flavored = true
expect(ReverseMarkdown.config.github_flavored).to eq true
end
it 'can be used as a block configurator as well' do
ReverseMarkdown.config do |config|
expect(config.github_flavored).to eq false
config.github_flavored = true
end
expect(ReverseMarkdown.config.github_flavored).to eq true
end
describe 'force_encoding option', jruby: :exclude do
it 'raises invalid byte sequence in UTF-8 exception' do
expect { ReverseMarkdown.convert("hi \255") }.to raise_error(ArgumentError)
end
it 'handles invalid byte sequence if option is set' do
expect(ReverseMarkdown.convert("hi \255", force_encoding: true)).to eq "hi\n\n"
end
end
end
end
reverse_markdown-1.4.0/spec/lib/reverse_markdown/ 0000755 0000041 0000041 00000000000 13605223630 022176 5 ustar www-data www-data reverse_markdown-1.4.0/spec/lib/reverse_markdown/converters/ 0000755 0000041 0000041 00000000000 13605223630 024370 5 ustar www-data www-data reverse_markdown-1.4.0/spec/lib/reverse_markdown/converters/del_spec.rb 0000644 0000041 0000041 00000002320 13605223630 026470 0 ustar www-data www-data require 'spec_helper'
describe ReverseMarkdown::Converters::Del do
let(:converter) { ReverseMarkdown::Converters::Del.new }
context 'with github_flavored = true' do
before { ReverseMarkdown.config.github_flavored = true }
it 'converts the input as expected' do
input = node_for('tell application Foo
beep
end tell
deldeldel')
expect(converter.convert(input)).to eq '~~deldeldel~~'
end
it 'converts the input as expected' do
input = node_for('strike that')
expect(converter.convert(input)).to eq '~~strike that~~'
end
it 'skips empty tags' do
input = node_for('')
expect(converter.convert(input)).to eq ''
end
it 'knows about its enabled/disabled state' do
expect(converter).to be_enabled
expect(converter).not_to be_disabled
end
end
context 'with github_flavored = false' do
before { ReverseMarkdown.config.github_flavored = false }
it 'does not convert anything' do
input = node_for('deldeldel')
expect(converter.convert(input)).to eq 'deldeldel'
end
it 'knows about its enabled/disabled state' do
expect(converter).not_to be_enabled
expect(converter).to be_disabled
end
end
end
reverse_markdown-1.4.0/spec/lib/reverse_markdown/converters/li_spec.rb 0000644 0000041 0000041 00000000457 13605223630 026341 0 ustar www-data www-data require 'spec_helper'
describe ReverseMarkdown::Converters::Li do
let(:converter) { ReverseMarkdown::Converters::Li.new }
it 'does not fail without a valid parent context' do
input = node_for("puts foo
")
expect(converter.convert(node)).to include " puts foo\n"
end
it 'preserves new lines' do
node = node_for("one
")
expect(converter.convert(node)).to include "\n\n one\n two\n three\n\n"
end
it 'handles code tags correctly' do
node = node_for("
two
three
")
expect(converter.convert(node)).to eq "\n\n foobar\n\n"
end
it 'handles indented correctly' do
node = node_for("foobar
")
expect(converter.convert(node)).to eq "\n\n if foo\n return bar\n end\n\n"
end
end
context 'for github_flavored markdown' do
before { ReverseMarkdown.config.github_flavored = true }
it 'converts with backticks' do
node = node_for("if foo\n return bar\nendputs foo
")
expect(converter.convert(node)).to include "```\nputs foo\n```"
end
it 'preserves new lines' do
node = node_for("foo
")
expect(converter.convert(node)).to include "```\nfoo\nbar\n```"
end
it 'handles code tags correctly' do
node = node_for("
bar
")
expect(converter.convert(node)).to include "```\nfoobar\n```"
end
context 'syntax highlighting' do
it 'works for "highlight-lang" mechanism' do
div = node_for("foobarputs foo
puts foo
")
expect(converter.convert(pre)).to include "```html/xml\n"
end
end
end
end
reverse_markdown-1.4.0/spec/lib/reverse_markdown/converters/text_spec.rb 0000644 0000041 0000041 00000003570 13605223630 026720 0 ustar www-data www-data require 'spec_helper'
describe ReverseMarkdown::Converters::Text do
let(:converter) { ReverseMarkdown::Converters::Text.new }
it 'treats newline within text as a single whitespace' do
input = node_for("
")
result = converter.convert(input)
expect(result).to eq "\n\n> - foo\n\n"
end
it 'can deal with paragraphs inside' do
input = node_for("
")
result = converter.convert(input)
expect(result).to eq "\n\n> Some text.\n> \n> Some more text.\n\n"
end
end
reverse_markdown-1.4.0/spec/lib/reverse_markdown/converters/strong_spec.rb 0000644 0000041 0000041 00000001274 13605223630 027247 0 ustar www-data www-data require 'spec_helper'
describe ReverseMarkdown::Converters::Strong do
let(:converter) { ReverseMarkdown::Converters::Strong.new }
it 'returns an empty string if the node is empty' do
input = node_for('')
expect(converter.convert(input)).to eq ''
end
it 'returns just the content if the strong tag is nested in another strong' do
input = node_for('foo')
expect(converter.convert(input.children.first, already_strong: true)).to eq 'foo'
end
it 'moves border whitespaces outside of the delimiters tag' do
input = node_for(" \n foo ")
expect(converter.convert(input)).to eq " **foo** "
end
end
reverse_markdown-1.4.0/spec/lib/reverse_markdown/converters/br_spec.rb 0000644 0000041 0000041 00000000364 13605223630 026335 0 ustar www-data www-data require 'spec_helper'
describe ReverseMarkdown::Converters::Br do
let(:converter) { ReverseMarkdown::Converters::Br.new }
it 'just converts into two spaces and a newline' do
expect(converter.convert(:anything)).to eq " \n"
end
end
reverse_markdown-1.4.0/spec/lib/reverse_markdown/converters_spec.rb 0000644 0000041 0000041 00000001114 13605223630 025724 0 ustar www-data www-data require 'spec_helper'
describe ReverseMarkdown::Converters do
before { ReverseMarkdown.config.unknown_tags = :raise }
let(:converters) { ReverseMarkdown::Converters }
describe '.register and .unregister' do
it 'adds a converter mapping to the list' do
expect { converters.lookup(:foo) }.to raise_error ReverseMarkdown::UnknownTagError
converters.register :foo, :foobar
expect(converters.lookup(:foo)).to eq :foobar
converters.unregister :foo
expect { converters.lookup(:foo) }.to raise_error ReverseMarkdown::UnknownTagError
end
end
end
reverse_markdown-1.4.0/spec/lib/reverse_markdown/config_spec.rb 0000644 0000041 0000041 00000001314 13605223630 025001 0 ustar www-data www-data require 'spec_helper'
describe ReverseMarkdown::Config do
describe '#with' do
let(:config) { ReverseMarkdown.config }
it 'takes additional options into account' do
config.with(github_flavored: :foobar) do
expect(ReverseMarkdown.config.github_flavored).to eq :foobar
end
end
it 'returns the result of a given block' do
expect(config.with { :something }).to eq :something
end
it 'resets to original settings afterwards' do
config.github_flavored = :foo
config.with(github_flavored: :bar) do
expect(ReverseMarkdown.config.github_flavored).to eq :bar
end
expect(ReverseMarkdown.config.github_flavored).to eq :foo
end
end
end
reverse_markdown-1.4.0/spec/lib/reverse_markdown/cleaner_spec.rb 0000644 0000041 0000041 00000012522 13605223630 025150 0 ustar www-data www-data require 'spec_helper'
describe ReverseMarkdown::Cleaner do
let(:cleaner) { ReverseMarkdown::Cleaner.new }
describe '#remove_newlines' do
it 'removes more than 2 subsequent newlines' do
result = cleaner.remove_newlines("foo\n\n\nbar")
expect(result).to eq "foo\n\nbar"
end
it 'skips single and double newlines' do
result = cleaner.remove_newlines("foo\nbar\n\nbaz")
expect(result).to eq "foo\nbar\n\nbaz"
end
end
describe '#remove_inner_whitespaces' do
it 'removes duplicate whitespaces from the string' do
result = cleaner.remove_inner_whitespaces('foo bar')
expect(result).to eq "foo bar"
end
it 'performs changes for multiple lines' do
result = cleaner.remove_inner_whitespaces("foo bar\nbar foo")
expect(result).to eq "foo bar\nbar foo"
end
it 'keeps leading whitespaces' do
result = cleaner.remove_inner_whitespaces(" foo bar\n bar foo")
expect(result).to eq " foo bar\n bar foo"
end
it 'keeps trailing whitespaces' do
result = cleaner.remove_inner_whitespaces("foo \n")
expect(result).to eq "foo \n"
end
it 'keeps trailing newlines' do
result = cleaner.remove_inner_whitespaces("foo\n")
expect(result).to eq "foo\n"
end
it 'removes tabs as well' do
result = cleaner.remove_inner_whitespaces("foo\t \tbar")
expect(result).to eq "foo bar"
end
it 'keeps lines that only contain whitespace' do
result = cleaner.remove_inner_whitespaces("foo \nbar \n \n \nfoo")
expect(result).to eq "foo \nbar \n \n \nfoo"
end
end
describe '#clean_punctuation_characters' do
it 'removes whitespace between tag end and punctuation characters' do
input = "**fat** . ~~strike~~ ? __italic__ ! "
result = cleaner.clean_punctuation_characters(input)
expect(result).to eq "**fat**. ~~strike~~? __italic__! "
end
end
describe '#clean_tag_borders' do
context 'with default_border is set to space' do
before { ReverseMarkdown.config.tag_border = ' ' }
it 'removes not needed whitespaces from strong tags' do
input = "foo ** foobar ** bar"
result = cleaner.clean_tag_borders(input)
expect(result).to eq "foo **foobar** bar"
end
it 'remotes leading or trailing whitespaces independently' do
input = "1 **fat ** 2 ** fat** 3"
result = cleaner.clean_tag_borders(input)
expect(result).to eq "1 **fat** 2 **fat** 3"
end
it 'adds whitespaces if there are none' do
input = "1**fat**2"
result = cleaner.clean_tag_borders(input)
expect(result).to eq "1 **fat** 2"
end
it "doesn't add whitespaces to underscore'ed elements if they are part of links" do
input = ""
result = cleaner.clean_tag_borders(input)
expect(result).to eq ""
end
it "still cleans up whitespaces that aren't inside a link" do
input = "now __italic __with following [under__scored](link)"
result = cleaner.clean_tag_borders(input)
expect(result).to eq "now __italic__ with following [under__scored](link)"
end
it 'cleans italic stuff as well' do
input = "1 __italic __ 2 __ italic__ 3__italic __4"
result = cleaner.clean_tag_borders(input)
expect(result).to eq "1 __italic__ 2 __italic__ 3 __italic__ 4"
end
it 'cleans strikethrough stuff as well' do
input = "1 ~~italic ~~ 2 ~~ italic~~ 3~~italic ~~4"
result = cleaner.clean_tag_borders(input)
expect(result).to eq "1 ~~italic~~ 2 ~~italic~~ 3 ~~italic~~ 4"
end
end
context 'with default_border set to no space' do
before { ReverseMarkdown.config.tag_border = '' }
it 'removes not needed whitespaces from strong tags' do
input = "foo ** foobar ** bar"
result = cleaner.clean_tag_borders(input)
expect(result).to eq "foo **foobar** bar"
end
it 'remotes leading or trailing whitespaces independently' do
input = "1 **fat ** 2 ** fat** 3"
result = cleaner.clean_tag_borders(input)
expect(result).to eq "1 **fat** 2 **fat** 3"
end
it 'adds whitespaces if there are none' do
input = "1**fat**2"
result = cleaner.clean_tag_borders(input)
expect(result).to eq "1**fat**2"
end
it "doesn't add whitespaces to underscore'ed elements if they are part of links" do
input = ""
result = cleaner.clean_tag_borders(input)
expect(result).to eq ""
end
it "still cleans up whitespaces that aren't inside a link" do
input = "now __italic __with following [under__scored](link)"
result = cleaner.clean_tag_borders(input)
expect(result).to eq "now __italic__with following [under__scored](link)"
end
it 'cleans italic stuff as well' do
input = "1 __italic __ 2 __ italic__ 3__italic __4"
result = cleaner.clean_tag_borders(input)
expect(result).to eq "1 __italic__ 2 __italic__ 3__italic__4"
end
it 'cleans strikethrough stuff as well' do
input = "1 ~~italic ~~ 2 ~~ italic~~ 3~~italic ~~4"
result = cleaner.clean_tag_borders(input)
expect(result).to eq "1 ~~italic~~ 2 ~~italic~~ 3~~italic~~4"
end
end
end
end
reverse_markdown-1.4.0/spec/components/ 0000755 0000041 0000041 00000000000 13605223630 020240 5 ustar www-data www-data reverse_markdown-1.4.0/spec/components/paragraphs_spec.rb 0000644 0000041 0000041 00000001104 13605223630 023723 0 ustar www-data www-data require 'spec_helper'
describe ReverseMarkdown do
let(:input) { File.read('spec/assets/paragraphs.html') }
let(:document) { Nokogiri::HTML(input) }
subject { ReverseMarkdown.convert(input) }
it { is_expected.not_to start_with "\n\n" }
it { is_expected.to start_with "First content\n\nSecond content\n\n" }
it { is_expected.to include "\n\n_Complex_\n\n Content" }
it { is_expected.to include "**Trailing whitespace:**" }
it { is_expected.to include "**Trailing non-breaking space: **" }
it { is_expected.to include "**_Combination: _**" }
end
reverse_markdown-1.4.0/spec/components/quotation_spec.rb 0000644 0000041 0000041 00000000537 13605223630 023627 0 ustar www-data www-data require 'spec_helper'
describe ReverseMarkdown do
let(:input) { File.read('spec/assets/quotation.html') }
let(:document) { Nokogiri::HTML(input) }
subject { ReverseMarkdown.convert(input) }
it { is_expected.to match /^ Block of code$/ }
it { is_expected.to include "\n> First quoted paragraph\n> \n> Second quoted paragraph" }
end
reverse_markdown-1.4.0/spec/components/unknown_tags_spec.rb 0000644 0000041 0000041 00000002133 13605223630 024313 0 ustar www-data www-data require 'spec_helper'
describe ReverseMarkdown do
let(:input) { File.read('spec/assets/unknown_tags.html') }
let(:document) { Nokogiri::HTML(input) }
let(:result) { ReverseMarkdown.convert(input) }
context 'with unknown_tags = :pass_through' do
before { ReverseMarkdown.config.unknown_tags = :pass_through }
it { expect(result).to include "
header 1
header 2
header 3
data 1-1
data 2-1
data 3-1
data 1-2
data 2-2
data 3-2
footer 1
footer 2
footer 3
some text...
reverse_markdown-1.4.0/spec/assets/quotation.html 0000644 0000041 0000041 00000000305 13605223630 022264 0 ustar www-data www-data
header oblique
header bold
header code
data oblique
data bold
data code
Block of code
reverse_markdown-1.4.0/spec/assets/anchors.html 0000644 0000041 0000041 00000002306 13605223630 021701 0 ustar www-data www-data
some text...
Foobar
Fubar
Strong foobar
There should be no extra space before and after the anchor (stripped).
Exception: after an !there should be an extra space.
Even with stripped elements inbetween: !there should be an extra space.
ignore anchor tags with no link text
not ignore
anchor tags with images
pass through the text of internal jumplinks without treating them as links
pass through the text of anchor tags with no href without treating them as links
some text...
some text...
reverse_markdown-1.4.0/spec/assets/html_fragment.html 0000644 0000041 0000041 00000000057 13605223630 023074 0 ustar www-data www-data naked text 1
reverse_markdown-1.4.0/spec/assets/escapables.html 0000644 0000041 0000041 00000000351 13605223630 022344 0 ustar www-data www-data
some text...
**two asterisks**
***three asterisks***
__two underscores__
___three underscores___
some text...
reverse_markdown-1.4.0/spec/assets/full_example.html 0000644 0000041 0000041 00000001456 13605223630 022726 0 ustar www-data www-data
var theoretical_max_infin = 1.0;
h1
h2
h3
h4
Block of code
link
reverse_markdown-1.4.0/spec/assets/unknown_tags.html 0000644 0000041 0000041 00000000154 13605223630 022760 0 ustar www-data www-data
pre block
code block
pre code blockcode block
Code with indentation:
var this;
this.is("A multi line code block")
console.log("Yup, it is")
reverse_markdown-1.4.0/spec/assets/minimum.html 0000644 0000041 0000041 00000000042 13605223630 021712 0 ustar www-data www-data
reverse_markdown-1.4.0/spec/assets/from_the_wild.html 0000644 0000041 0000041 00000000477 13605223630 023075 0 ustar www-data www-data tell application "Foo"
beep
end tell
*** intentcast
: logo design
.
I\_AM\_HELPFUL
reverse_markdown-1.4.0/spec/assets/basic.html 0000644 0000041 0000041 00000002720 13605223630 021325 0 ustar www-data www-data
plain text
h1
h2
h3
h4
h5
h6
em tag content
before and after empty em tags
before and after em tags containing whitespace
before
and after em tags containing whitespace
double em tags
and after strong tags containing whitespace
double strong tags
before hr
after hr
Content
Trailing whitespace:
Trailing non-breaking space:
Combination: