mirror of
https://github.com/ralsina/tartrazine.git
synced 2025-06-18 22:23:07 -03:00
feat: higher level API (to_html
and to_ansi
)
Some checks failed
Tests / build (push) Has been cancelled
Some checks failed
Tests / build (push) Has been cancelled
This commit is contained in:
@ -69,6 +69,31 @@ describe Tartrazine do
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "to_html" do
|
||||
it "should do basic highlighting" do
|
||||
html = Tartrazine.to_html("puts 'Hello, World!'", "ruby", standalone: false)
|
||||
html.should eq(
|
||||
"<pre class=\"b\" ><code class=\"b\"><span class=\"nb\">puts</span><span class=\"t\"> </span><span class=\"lss\">'Hello, World!'</span></code></pre>"
|
||||
)
|
||||
end
|
||||
end
|
||||
describe "to_ansi" do
|
||||
it "should do basic highlighting" do
|
||||
ansi = Tartrazine.to_ansi("puts 'Hello, World!'", "ruby")
|
||||
if ENV.fetch("CI", nil)
|
||||
# In Github Actions there is no terminal so these don't
|
||||
# really work
|
||||
ansi.should eq(
|
||||
"puts 'Hello, World!'"
|
||||
)
|
||||
else
|
||||
ansi.should eq(
|
||||
"\e[38;2;171;70;66mputs\e[0m\e[38;2;216;216;216m \e[0m'Hello, World!'"
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# Helper that creates lexer and tokenizes
|
||||
|
Reference in New Issue
Block a user