#!/usr/bin/env ruby require File.join(File.dirname(__FILE__), "..", "spec_helper") describe "Macro:" do before do reset_quiet create_project Glyph['document.output'] = 'html5' Glyph.run! 'load:all' end after do Glyph.lite_mode = false reset_quiet delete_project end it "section, chapter, header (html5)" do text = "chapter[@title[Chapter X] ... section[@title[Section Y]@id[sec-y] ... section[@title[Another section] ...]]]" interpret text doc = @p.document expect(doc.output.gsub(/\n|\t/, '')).to eq(%{

Chapter X

...

Section Y

...

Another section

...
}.gsub(/\n|\t/, '')) expect(doc.bookmark?(:"sec-y")).to eq(Glyph::Bookmark.new({:id => :"sec-y", :title => "Section Y", :file => nil})) end it "document, head, style (html5)" do interpret "document[head[style[test.sass]]]" expect(@p.document.output.gsub(/\n|\t/, '')).to eq(%{ #{Glyph::CONFIG.get("document.title")} }.gsub(/\n|\t/, '')) end it "toc (html5)" do file_copy Glyph::PROJECT/'../files/document_with_toc.glyph', Glyph::PROJECT/'document.glyph' interpret file_load(Glyph::PROJECT/'document.glyph') doc = @p.document doc.output.gsub!(/\n|\t/, '') expect(doc.output.slice(/(.+?<\/nav>)/, 1)).to eq(%{ }.gsub(/\n|\t/, '')) end it "fmi (html5)" do interpret "fmi[this topic|#test] #[test|Test]" expect(@p.document.output).to eq(%{ for more information on this topic, see Test Test}.gsub(/\n|\t/, '')) end it "figure (html5)" do interpret "figure[@alt[ligature]ligature.jpg|Ligature]" expect(@p.document.output.gsub(/\t|\n/, '')).to eq(%{
Ligature
}.gsub(/\n|\t/, '')) end it "draftcomment, todo (html5)" do text1 = "dc[comment!]" text2 = "![todo!]" interpret text1 expect(@p.document.output).to eq("") interpret text2 expect(@p.document.output).to eq("") Glyph['document.draft'] = true interpret text1 expect(@p.document.output).to eq(%{}) interpret text2 expect(@p.document.output).to eq(%{}) expect(@p.document.todos.length).to eq(1) Glyph['document.draft'] = false end end