Module: HeadMusic::Notation::MusicXML::XmlText

Included in:
LyricWriter, NoteWriter, Writer
Defined in:
lib/head_music/notation/music_xml/xml_text.rb

Overview

The text primitives the MusicXML serializers share: the document’s indent unit and the character escapes XML requires in element content.

Constant Summary collapse

INDENT =
"  "
ESCAPES =
{
  "&" => "&",
  "<" => "&lt;",
  ">" => "&gt;",
  '"' => "&quot;",
  "'" => "&apos;"
}.freeze

Instance Method Summary collapse

Instance Method Details

#escape(text) ⇒ Object (private)



17
18
19
# File 'lib/head_music/notation/music_xml/xml_text.rb', line 17

def escape(text)
  text.to_s.gsub(/[&<>"']/) { |character| ESCAPES[character] }
end