Skip to content

Commit

Permalink
The whole book compiles with no errors.
Browse files Browse the repository at this point in the history
  • Loading branch information
h3rald committed Jun 12, 2010
1 parent c216a52 commit df664b9
Show file tree
Hide file tree
Showing 11 changed files with 145 additions and 163 deletions.
3 changes: 1 addition & 2 deletions book/lib/macros/reference.rb
Expand Up @@ -76,7 +76,6 @@
end

macro :block_example do
@node[:source] = {:node => @node, :name => "block_example[]"}
interpret %{
div[@class[example]
p[strong[Example]]
Expand Down Expand Up @@ -140,7 +139,7 @@
default = "nil" if default.blank?
interpret %{tr[
td[codeph[#{m_name}] #[s_#{m_name.gsub(/\./, '_')}]]
td[#{m_value}]
td[txt[#{m_value}]]
td[
code[=
#{default}
Expand Down
201 changes: 97 additions & 104 deletions book/output/html/glyph.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion book/text/changelog.glyph
Expand Up @@ -56,7 +56,7 @@ release[0.2.0|May 9th 2010|
issue[101|Additional tests have been developed to improve Textile support. There should no longer be errors when using textile block elements inside Glyph macros.]
issue[103|Fixed a bug that caused test failures when deleting the test project directory.]
issue[104|Nested Glyph macros calling @Macro#interpret@ no longer ignore escape delimiters.]
issue[107|Added the possibility to encode (using the %>[encode]) and decode (using the %>[decode]) macros so that they can be interpreted later.]
issue[107|Added the possibility to encode (using the @encode@ macro) and decode (using the @decode@ macro) macros so that they can be interpreted later.]
]
]
release[0.1.0|April 8th 2010|
Expand Down
2 changes: 1 addition & 1 deletion book/text/extending/interpreting.glyph
Expand Up @@ -36,7 +36,7 @@ macro :issue do
}
end
=]
p[The code[issue] macro is only rewriting existing Glyph code around the two parameters provided. In this case, it is possible to do exactly the same thing using the %>[rewrite]:]
p[The code[issue] macro is only rewriting existing Glyph code around the two parameters provided. In this case, it is possible to do exactly the same thing using the %>[rewrite:]:]
highlight[=html|
rewrite:[issue\|
tr[
Expand Down
71 changes: 27 additions & 44 deletions book/text/ref_config.glyph
@@ -1,4 +1,3 @@
![Remove system settings from documentation]
section[
@title[document.*]
@id[cfg_document]
Expand All @@ -19,6 +18,9 @@ The format of the output file. It can be set to any value stored in the $>[docum
]
ref_config[document.output_targets|
An @Array@ containing all the possible output formats. This setting should not be changed by the user.
]
ref_config[document.revision|
The document's revision.
]
ref_config[document.source|
The main source file to compile. It can be also be overridden by calling the #>[compile] with the @-s@ option.
Expand All @@ -34,8 +36,8 @@ The title of the document, displayed using the %>[title].
] --[End document section]

section[
@title[filters.*]
@id[cfg_filters]
@title[filters.*]
@id[cfg_filters]
config_table[
ref_config[filters.by_file_extension|
If set to @true@, a filter macro is applied to included files, based on their extensions (\.fmi[including files|#incl]).
Expand All @@ -48,70 +50,51 @@ The name of the markdown converter to use with the %>[markdown]. It can be set t
* Kramdown

If not set, Glyph tests for the presence of each gem in the same order, until one is found.
]
ref_config[filters.coderay.*|
Some &[coderay]-specific =>[http://coderay.rubychan.de/doc/classes/CodeRay/Encoders/HTML.html|options].
]
ref_config[filters.highlighter|
The current highlighter to use. It can be set to @coderay@ or @ultraviolet@
]
ref_config[filters.redcloth.restrictions|
An @Array@ containing restrictions applied to RedCloth, used by the %>[textile] (see =>[http://redcloth.rubyforge.org/classes/RedCloth/TextileDoc.html|RedCloth Documentation] for more information).
]
ref_config[filters.target|
The output target for filters. It can be set to @html@ (for RedCloth and MarkDown) or @latex@ (RedCloth-only).
]
]
] --[End filters section]


section[
@title[highlighters.*]
@id[s_highlighters]

config_table[
ref_config[highlighters.coderay.*|
Some &[coderay]-specific =>[http://coderay.rubychan.de/doc/classes/CodeRay/Encoders/HTML.html|options].
]
ref_config[highlighters.current|
The current highlighter to use. It can be set to @coderay@ or @ultraviolet@
]
ref_config[highlighters.target|
The target output of the =>[#s_highlighters_current|current highlighter]. It can be set to anything the highlighter supports.
]
ref_config[highlighters.ultraviolet.line_numbers|
ref_config[filters.ultraviolet.line_numbers|
Whether the &[uv] highlighter should display line numbers or not.
]
ref_config[highlighters.ultraviolet.theme|
ref_config[filters.ultraviolet.theme|
The theme used by the &[uv] highlighter.
]
]

] --[End highlighters section]
]

section[
@title[structure.*]
The following configuration settings are used internally by Glyph and should not be changed by the user.

@title[language.*]
config_table[
ref_config[structure.backmatter|
The section types used in the document backmatter.
]
ref_config[structure.bodymatter|
The section types used in the document bodymatter.
ref_config[language.set|
Determines which macro set will be loaded. It can be set to:
* glyph – Loads core, filter, xml macros plus all macros necessary for the $>[document.output].
* xml – Loads core and xml macros.
* core – Loads core macros only.
]
ref_config[structure.frontmatter|
The section types used in the document frontmatter.
ref_config[language.options.xml_blacklist|
The XML tags listed here cannot be generated using Glyph code.
]
ref_config[structure.hidden|
The section types that will not be shown in the Table of Contents.
]
ref_config[structure.special|
The section types that will be considered _special_ and whose children will not be included in the Table of Contents.
ref_config[language.options.xml_fallback|
If set to true, any unknown macro name will considered an XML element (see =>[#other_elements]).
]
]
] --[End structure section]
]

section[
@title[tools.*]
@title[tools.*]
config_table[
ref_config[tools.pdf_generator|
The external program used to generate PDF files. It can only be set to @prince@.
]
]
] --[End tools section]

]
2 changes: 1 addition & 1 deletion book/text/text_editing/code.glyph
Expand Up @@ -2,7 +2,7 @@ section[
@title[Source Code]
@id[source_code]
txt[
If you're a programmer, chances are that you're going to include some source code in your articles and books. Glyph offers two ways to format code blocks effortlessly: the %>[code], which simply wraps text into @<pre>@ and @<code>@ tags, or the %>[highlight]. The last one requires either &[coderay] or &[uv], but it provides syntax highlighting for the most common programming languages.
If you're a programmer, chances are that you're going to include some source code in your articles and books. Glyph offers two ways to format code blocks effortlessly: the %>[codeblock], which simply wraps text into @<pre>@ and @<code>@ tags, or the %>[highlight]. The last one requires either &[coderay] or &[uv], but it provides syntax highlighting for the most common programming languages.

Cosider the following piece of ruby code:
]
Expand Down
2 changes: 1 addition & 1 deletion book/text/text_editing/macro_intro.glyph
Expand Up @@ -49,7 +49,7 @@ Glyph doesn't require any special control characters like LaTeX, and its macro s

If a portion of your text contains an excessive amount of square brackets, you may consider using the %>[escape] (or its alias @.@) with the @\[=@ and @=\]@ delimiters. By itself, the escape macro doesn't do anything: it just evaluates to its contents, but the special delimiters act as an escape for any square bracket within them. As a consequence, any macro within @\[=@ and @=\]@ will _not_ be evaluated.

You can use the quoting delimiters with _any_ macro identifier. Obviously, using them as delimiters for things like %>[section]s may not be a good idea, but they should be more or less mandatory with the %>[code], especially when it contains square brackets or even Glyph code, like this:
You can use the quoting delimiters with _any_ macro identifier. Obviously, using them as delimiters for things like %>[section]s may not be a good idea, but they should be more or less mandatory with the %>[codeblock] or the %>[highlight], especially when it contains square brackets or even Glyph code, like this:
]

highlight[=html|
Expand Down
2 changes: 1 addition & 1 deletion book/text/text_editing/stylesheets.glyph
Expand Up @@ -7,7 +7,7 @@ section[
txt[In this case, the %>[style] looks for a @default.css@ file in the @/styles@ folder of your Glyph project _and_ among the default Glyph stylesheets, and embeds it within a @<style>@ tag. If you supply a file with a @.sass@ extension, it will interpret it as a Sass file and convert it to CSS automatically (if the _Haml_ gem is installed).]
section[
@title[Default Stylesheets]
@id[default_styles]
@id[default_stylesheets]
p[Glyph provides the following default stylesheets, that can be referenced directly using the %>[style]:]
table[
tr[
Expand Down
8 changes: 4 additions & 4 deletions book/text/troubleshooting/errors_macro.glyph
Expand Up @@ -29,7 +29,7 @@ Returned if the macro was called with a different number of parameters than.
Returned by the %>[include] if used in =>[#lite_mode|lite mode].
]
ref_error[Filter macro '\.em[extension]' not available|
Returned by a filter macro if $>[filters.byem[file]extension] is set to @true@, but the extension was not recognized.
Returned by a filter macro if $>[filters.by_file_extension] is set to @true@, but the extension was not recognized.
]
ref_error[Invalid regular expression: em[regexp]|
Returned by the %>[match] if an invalid regular expression was supplied.
Expand All @@ -41,10 +41,10 @@ Returned if the macro was called with parameters but none are requested.
Returned by the %>[highlight] if no highlighters are installed.
]
ref_error[CodeRay highlighter not installed. Please run: gem install coderay|
Returned by the %>[highlight] if $>[highlighters.current] is set to @coderay@ but &[coderay] is not installed.
Returned by the %>[highlight] if $>[filters.highlighter] is set to @coderay@ but &[coderay] is not installed.
]
ref_error[UltraViolet highlighter not installed. Please run: gem install ultraviolet|
Returned by the %>[highlight] if $>[highlighters.current] is set to @ultraviolet@ but &[uv] is not installed.
Returned by the %>[highlight] if $>[filters.highlighter] is set to @ultraviolet@ but &[uv] is not installed.
]
ref_error[Mutual Inclusion in parameter/attribute(\.em[name]): '\.em[value]'|
Returned if a catch-22 situation occurs with macro inclusion, for example if the value of a snippet includes a reference to the same snippet.
Expand All @@ -68,7 +68,7 @@ Returned by the %>[markdown] if no valid Markdown converter gem is installed. Gl
Retured by the %>[image] or the %>[figure] respectively, if the specified image file could not be found within the code[images/] folder.
]
ref_error[Bookmark '\.em[bookmark_name]' already exists|
Returned by the %>[anchor] or by the %>[header] if the anchor ID supplied as parameter has already been used in the document.
Returned by the %>[anchor] or by the %>[section] if the anchor ID supplied as attribute has already been used in the document.
]
ref_error[Bookmark '\.em[bookmark_name]' already exists|
Returned by the %>[link] if the anchor ID supplied as parameter has not been used in the document.
Expand Down
11 changes: 9 additions & 2 deletions lib/glyph/macro.rb
Expand Up @@ -16,9 +16,16 @@ class Macro
def initialize(node)
@node = node
@name = @node[:name]
@embedded_source = nil
@updated_source = nil
@source = @node[:source][:name] rescue "--"
end

# Resets the name of the updated source (call before calling
# Macro#interpret)
# @param [String] name the source name
def update_source(name)
@updated_source = {:node => @node, :name => name}
end

# Returns a Glyph code representation of the specified parameter
# @param [Fixnum] n the index of the parameter
Expand Down Expand Up @@ -194,7 +201,7 @@ def interpret(string)
result = string
else
context = {}
context[:source] = @embedded_source || {:node => @node, :name => "#@name[...]"}
context[:source] = @updated_source || @node[:source]
context[:embedded] = true
context[:document] = @node[:document]
interpreter = Glyph::Interpreter.new string, context
Expand Down
4 changes: 2 additions & 2 deletions macros/core.rb
Expand Up @@ -5,7 +5,7 @@
ident = value.to_sym
if Glyph::SNIPPETS.has_key? ident then
begin
@embedded_source = {:node => @node, :name => "snippet[#{ident}]"}
update_source "snippet[#{ident}]"
interpret Glyph::SNIPPETS[ident]
rescue Exception => e
case
Expand Down Expand Up @@ -77,7 +77,7 @@
end
end
begin
@embedded_source = {:node => @node, :name => v}
update_source v
interpret contents
rescue Glyph::MutualInclusionError => e
raise
Expand Down

0 comments on commit df664b9

Please sign in to comment.