Repository: decorators-squad/eo-yaml
Pull request #195 (2020-03-13 13:20:38)

added NoDirectivesOrMarkers
PR for #128 
When reading a YamlMapping or a YamlSequence (so not a Yaml Stream), YAML Directives and Markers (such as ``---`` or ``...``) are ignored.


Patch:
diff --git a/src/main/java/com/amihaiemil/eoyaml/NoDirectivesOrMarkers.java b/src/main/java/com/amihaiemil/eoyaml/NoDirectivesOrMarkers.java
new file mode 100644
index 0000000..c1faae1
--- /dev/null
+++ b/src/main/java/com/amihaiemil/eoyaml/NoDirectivesOrMarkers.java
@@ -0,0 +1,95 @@
+/**
+ * Copyright (c) 2016-2020, Mihai Emil Andronache
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions are met:
+ * Redistributions of source code must retain the above copyright notice, this
+ *  list of conditions and the following disclaimer.
+ *  Redistributions in binary form must reproduce the above copyright notice,
+ *  this list of conditions and the following disclaimer in the documentation
+ *  and/or other materials provided with the distribution.
+ * Neither the name of the copyright holder nor the names of its
+ *  contributors may be used to endorse or promote products derived from
+ *  this software without specific prior written permission.
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+package com.amihaiemil.eoyaml;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+
+/**
+ * No directives or markers. Decorates some YamlLines
+ * and ignores YAML directives and markers from iteration.
+ * @author Mihai Andronache (amihaiemil@gmail.com)
+ * @version $Id$
+ * @since 3.1.2
+ */
+final class NoDirectivesOrMarkers implements YamlLines {
+
+    /**
+     * YamlLines.
+     */
+    private final YamlLines yamlLines;
+
+    /**
+     * Ctor.
+     * @param yamlLines The Yaml lines.
+     */
+    NoDirectivesOrMarkers(final YamlLines yamlLines) {
+        this.yamlLines = yamlLines;
+    }
+
+    /**
+     * Returns an iterator over these Yaml lines.
+     * It ignores the YAML Directives and Marker lines.
+     * @return Iterator over these yaml lines.
+     */
+    @Override
+    public Iterator<YamlLine> iterator() {
+        Iterator<YamlLine> iterator = this.yamlLines.iterator();
+        if (iterator.hasNext()) {
+            final List<YamlLine> noDirsOrMarks = new ArrayList<>();
+            while (iterator.hasNext()) {
+                final YamlLine current = iterator.next();
+                final String currentLine = current.trimmed();
+                if (
+                    "---".equals(currentLine)
+                        || "...".equals(currentLine)
+                        || currentLine.startsWith("%")
+                        || currentLine.startsWith("!!")
+                ) {
+                    continue;
+                } else {
+                    noDirsOrMarks.add(current);
+                }
+            }
+            iterator = noDirsOrMarks.iterator();
+        }
+        return iterator;
+    }
+
+    @Override
+    public Collection<YamlLine> lines() {
+        return this.yamlLines.lines();
+    }
+
+    @Override
+    public YamlNode toYamlNode(final YamlLine prev) {
+        return this.yamlLines.toYamlNode(prev);
+    }
+}
\ No newline at end of file
diff --git a/src/main/java/com/amihaiemil/eoyaml/ReadYamlMapping.java b/src/main/java/com/amihaiemil/eoyaml/ReadYamlMapping.java
index 147ee9e..3a9ac57 100644
--- a/src/main/java/com/amihaiemil/eoyaml/ReadYamlMapping.java
+++ b/src/main/java/com/amihaiemil/eoyaml/ReadYamlMapping.java
@@ -30,7 +30,9 @@ package com.amihaiemil.eoyaml;
 import java.util.*;
 
 /**
- * YamlMapping read from somewhere.
+ * YamlMapping read from somewhere. YAML directives and
+ * document start/end markers are ignored. This is assumed
+ * to be a plain YAML mapping.
  * @author Mihai Andronache (amihaiemil@gmail.com)
  * @version $Id$
  * @since 1.0.0
@@ -48,7 +50,11 @@ final class ReadYamlMapping extends ComparableYamlMapping {
      */
     ReadYamlMapping(final AllYamlLines lines) {
         this.lines = new SameIndentationLevel(
-            new WellIndented(lines)
+            new WellIndented(
+                new NoDirectivesOrMarkers(
+                    lines
+                )
+            )
         );
     }
 
diff --git a/src/main/java/com/amihaiemil/eoyaml/ReadYamlSequence.java b/src/main/java/com/amihaiemil/eoyaml/ReadYamlSequence.java
index 09e4c49..eed847e 100644
--- a/src/main/java/com/amihaiemil/eoyaml/ReadYamlSequence.java
+++ b/src/main/java/com/amihaiemil/eoyaml/ReadYamlSequence.java
@@ -51,7 +51,11 @@ final class ReadYamlSequence extends ComparableYamlSequence {
      */
     ReadYamlSequence(final AllYamlLines lines) {
         this.lines = new SameIndentationLevel(
-            new WellIndented(lines)
+            new WellIndented(
+                new NoDirectivesOrMarkers(
+                    lines
+                )
+            )
         );
     }
 
diff --git a/src/main/java/com/amihaiemil/eoyaml/RtYamlLine.java b/src/main/java/com/amihaiemil/eoyaml/RtYamlLine.java
index b3ec559..f6b55ab 100644
--- a/src/main/java/com/amihaiemil/eoyaml/RtYamlLine.java
+++ b/src/main/java/com/amihaiemil/eoyaml/RtYamlLine.java
@@ -100,7 +100,7 @@ final class RtYamlLine implements YamlLine {
     public boolean hasNestedNode() {
         final boolean result;
         final String specialCharacters = ":>|-?";
-
+        
         final CharSequence prevLineLastChar =
             this.trimmed().substring(this.trimmed().length()-1);
         if(specialCharacters.contains(prevLineLastChar)) {
diff --git a/src/main/java/com/amihaiemil/eoyaml/WellIndented.java b/src/main/java/com/amihaiemil/eoyaml/WellIndented.java
index f7d19f7..467f3d6 100644
--- a/src/main/java/com/amihaiemil/eoyaml/WellIndented.java
+++ b/src/main/java/com/amihaiemil/eoyaml/WellIndented.java
@@ -54,7 +54,7 @@ import java.util.List;
  * 
  * YamlLines wellIndented = new SameIndentationLevel(
  *     new WellIndented(
- *         new NoMarkersOrDirectives(
+ *         new NoDirectivesOrMarkers(
  *             lines
  *         )//ignore markers or directives
  *     )


Test patch:
diff --git a/src/test/java/com/amihaiemil/eoyaml/NoDirectivesOrMarkersTest.java b/src/test/java/com/amihaiemil/eoyaml/NoDirectivesOrMarkersTest.java
new file mode 100644
index 0000000..e07183f
--- /dev/null
+++ b/src/test/java/com/amihaiemil/eoyaml/NoDirectivesOrMarkersTest.java
@@ -0,0 +1,178 @@
+/**
+ * Copyright (c) 2016-2020, Mihai Emil Andronache
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions are met:
+ * Redistributions of source code must retain the above copyright notice, this
+ *  list of conditions and the following disclaimer.
+ *  Redistributions in binary form must reproduce the above copyright notice,
+ *  this list of conditions and the following disclaimer in the documentation
+ *  and/or other materials provided with the distribution.
+ * Neither the name of the copyright holder nor the names of its
+ *  contributors may be used to endorse or promote products derived from
+ *  this software without specific prior written permission.
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+package com.amihaiemil.eoyaml;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+
+import org.hamcrest.MatcherAssert;
+import org.hamcrest.Matchers;
+import org.junit.Test;
+import org.mockito.Mockito;
+
+/**
+ * Unit tests for {@link NoDirectivesOrMarkers}.
+ * @author Mihai Andronache (amihaiemil@gmail.com)
+ * @version $Id$
+ * @since 3.1.2
+ */
+public final class NoDirectivesOrMarkersTest {
+
+    /**
+     * NoDirectivesOrMarkers can return the encapsulated lines.
+     */
+    @Test
+    @SuppressWarnings("unchecked")
+    public void returnsLines() {
+        final YamlLines lines = Mockito.mock(YamlLines.class);
+        final Collection<YamlLine> collection = Mockito.mock(Collection.class);
+        Mockito.when(lines.lines()).thenReturn(collection);
+        MatcherAssert.assertThat(
+            new NoDirectivesOrMarkers(lines).lines(),
+            Matchers.is(collection)
+        );
+    }
+    
+    /**
+     * NoDirectivesOrMarkers can turn itself into YamlNode.
+     */
+    @Test
+    public void turnsIntoYamlNode() {
+        final YamlLines lines = Mockito.mock(YamlLines.class);
+        final YamlLine prev = Mockito.mock(YamlLine.class);
+        final YamlNode result = Mockito.mock(YamlNode.class);
+        Mockito.when(lines.toYamlNode(prev)).thenReturn(result);
+        MatcherAssert.assertThat(
+            new NoDirectivesOrMarkers(lines).toYamlNode(prev),
+            Matchers.is(result)
+        );
+    }
+    
+    /**
+     * NoDirectivesOrMarkers should ignore YAML directives
+     * and markers from iteration.
+     */
+    @Test
+    public void ignoresDirectivesAndMarkers() {
+        final List<YamlLine> lines = new ArrayList<>();
+        lines.add(new RtYamlLine("%YAML 1.2", 0));
+        lines.add(new RtYamlLine("---", 1));
+        lines.add(new RtYamlLine("first: something", 2));
+        lines.add(new RtYamlLine("second: ", 3));
+        lines.add(new RtYamlLine("  fourth: some", 4));
+        lines.add(new RtYamlLine("  fifth: values", 5));
+        lines.add(new RtYamlLine("third:", 6));
+        lines.add(new RtYamlLine("  - seq", 7));
+        lines.add(new RtYamlLine("...", 8));
+        final YamlLines ndmLines = new NoDirectivesOrMarkers(
+            new AllYamlLines(lines)
+        );
+        MatcherAssert.assertThat(
+            ndmLines,
+            Matchers.iterableWithSize(6)
+        );
+        final Iterator<YamlLine> iterator = ndmLines.iterator();
+        MatcherAssert.assertThat(
+            iterator.next().trimmed(),
+            Matchers.equalTo("first: something")
+        );
+        MatcherAssert.assertThat(
+            iterator.next().trimmed(),
+            Matchers.equalTo("second:")
+        );
+        MatcherAssert.assertThat(
+            iterator.next().trimmed(),
+            Matchers.equalTo("fourth: some")
+        );
+        MatcherAssert.assertThat(
+            iterator.next().trimmed(),
+            Matchers.equalTo("fifth: values")
+        );
+        MatcherAssert.assertThat(
+            iterator.next().trimmed(),
+            Matchers.equalTo("third:")
+        );
+        MatcherAssert.assertThat(
+            iterator.next().trimmed(),
+            Matchers.equalTo("- seq")
+        );
+    }
+    
+    /**
+     * NoDirectivesOrMarkers iterates over all the lines, since
+     * there are actually no directives or markers to ignore.
+     */
+    @Test
+    public void noDirectivesAndMarkersToIgnore() {
+        final List<YamlLine> lines = new ArrayList<>();
+        lines.add(new RtYamlLine("first: something", 0));
+        lines.add(new RtYamlLine("second: ", 1));
+        lines.add(new RtYamlLine("  fourth: some", 2));
+        lines.add(new RtYamlLine("  fifth: values", 3));
+        final YamlLines ndmLines = new NoDirectivesOrMarkers(
+            new AllYamlLines(lines)
+        );
+        MatcherAssert.assertThat(
+            ndmLines,
+            Matchers.iterableWithSize(4)
+        );
+        final Iterator<YamlLine> iterator = ndmLines.iterator();
+        MatcherAssert.assertThat(
+            iterator.next().trimmed(),
+            Matchers.equalTo("first: something")
+        );
+        MatcherAssert.assertThat(
+            iterator.next().trimmed(),
+            Matchers.equalTo("second:")
+        );
+        MatcherAssert.assertThat(
+            iterator.next().trimmed(),
+            Matchers.equalTo("fourth: some")
+        );
+        MatcherAssert.assertThat(
+            iterator.next().trimmed(),
+            Matchers.equalTo("fifth: values")
+        );
+    }
+    
+    /**
+     * NoDirectivesOrMarkers works with no lines.
+     */
+    @Test
+    public void iteratesEmptyLines() {
+        final YamlLines ndmLines = new NoDirectivesOrMarkers(
+            new AllYamlLines(new ArrayList<YamlLine>())
+        );
+        MatcherAssert.assertThat(
+            ndmLines,
+            Matchers.iterableWithSize(0)
+        );
+    }
+}
diff --git a/src/test/java/com/amihaiemil/eoyaml/RtYamlInputTest.java b/src/test/java/com/amihaiemil/eoyaml/RtYamlInputTest.java
index ad53e86..ee9a93f 100644
--- a/src/test/java/com/amihaiemil/eoyaml/RtYamlInputTest.java
+++ b/src/test/java/com/amihaiemil/eoyaml/RtYamlInputTest.java
@@ -30,6 +30,7 @@ package com.amihaiemil.eoyaml;
 import java.io.ByteArrayInputStream;
 import java.io.File;
 import java.io.FileInputStream;
+import java.util.Set;
 
 import org.hamcrest.MatcherAssert;
 import org.hamcrest.Matchers;
@@ -101,28 +102,28 @@ public final class RtYamlInputTest {
     @Test
     public void readsAndIndentsComplexMapping() throws Exception {
         YamlMapping expected = Yaml.createYamlMappingBuilder()
-                .add("first", "value1")
-                .add("second", "value2")
-                .add("third",
-                    Yaml.createYamlSequenceBuilder()
-                        .add("singleElementSequence")
-                        .build()
-                ).add(
-                    Yaml.createYamlSequenceBuilder()
-                        .add("sequence")
-                        .add("key")
-                        .build(),
-                    "scalar"
-                ).add(
-                    Yaml.createYamlMappingBuilder()
-                        .add("map", "asKey")
-                        .add("map1", "asKey2")
-                        .build(),
-                    Yaml.createYamlMappingBuilder()
-                        .add("someMapping",  "value")
-                        .build()
-                )
-                .build();
+            .add("first", "value1")
+            .add("second", "value2")
+            .add("third",
+                Yaml.createYamlSequenceBuilder()
+                    .add("singleElementSequence")
+                    .build()
+            ).add(
+                Yaml.createYamlSequenceBuilder()
+                    .add("sequence")
+                    .add("key")
+                    .build(),
+                "scalar"
+            ).add(
+                Yaml.createYamlMappingBuilder()
+                    .add("map", "asKey")
+                    .add("map1", "asKey2")
+                    .build(),
+                Yaml.createYamlMappingBuilder()
+                    .add("someMapping",  "value")
+                    .build()
+            )
+            .build();
         System.out.println(expected);
         YamlMapping actual = new RtYamlInput(
             new FileInputStream(
@@ -166,6 +167,123 @@ public final class RtYamlInputTest {
         );
     }
 
+    /**
+     * At the moment, when reading a mapping, we should ignore any YAML
+     * Directive or Marker line, such as "%YAML 1.2" or "---" or "...".
+     * @throws Exception if something is wrong.
+     */
+    @Test
+    public void readsMappingWithoutDirectivesAndMarkers() throws Exception {
+        final YamlMapping mapping = new RtYamlInput(
+            new FileInputStream(
+                new File("src/test/resources/mapping_ignore_directives.yml")
+            )
+        ).readYamlMapping();
+        final Set<YamlNode> keys = mapping.keys();
+        MatcherAssert.assertThat(keys.size(), Matchers.equalTo(2));
+        MatcherAssert.assertThat(
+            keys.contains(new Scalar("palette")),
+            Matchers.is(Boolean.TRUE)
+        );
+        MatcherAssert.assertThat(
+            keys.contains(new Scalar("workspace")),
+            Matchers.is(Boolean.TRUE)
+        );        
+        
+        final YamlMapping palette = mapping.yamlMapping("palette");
+        MatcherAssert.assertThat(palette.keys().size(), Matchers.is(12));
+        MatcherAssert.assertThat(palette.values().size(), Matchers.is(12));
+        MatcherAssert.assertThat(
+            palette.string("gray"),
+            Matchers.is("'#404040'")
+        );
+        MatcherAssert.assertThat(
+            palette.string("magenta"),
+            Matchers.is("rgb(255, 102, 255)")
+        );
+        
+        final YamlMapping workspace = mapping.yamlMapping("workspace");
+        MatcherAssert.assertThat(workspace.keys().size(), Matchers.is(3));
+        MatcherAssert.assertThat(workspace.values().size(), Matchers.is(3));
+        MatcherAssert.assertThat(
+            workspace.string("background"),
+            Matchers.is("gray")
+        );
+        MatcherAssert.assertThat(
+            workspace.yamlMapping("elements")
+                .yamlMapping("devices")
+                .yamlMapping("pins")
+                .yamlSequence("active")
+                .string(1),
+            Matchers.is("hsl(163, 45%, 100%)")
+        );
+        MatcherAssert.assertThat(
+            workspace.yamlMapping("guides").string("grid"),
+            Matchers.is("stroke rgba(255, 255, 255, 0.3)")
+        );
+    }
+    
+    /**
+     * At the moment, when reading a sequence, we should ignore any YAML
+     * Directive or Marker line, such as "%YAML 1.2" or "---" or "...".
+     * @throws Exception if something is wrong.
+     */
+    @Test
+    public void readsSequenceWithoutDirectivesAndMarkers() throws Exception {
+        final YamlSequence sequence = new RtYamlInput(
+            new FileInputStream(
+                new File("src/test/resources/sequence_ignore_directives.yml")
+            )
+        ).readYamlSequence();
+        final YamlMapping first = sequence.yamlMapping(0);
+        MatcherAssert.assertThat(
+            first.keys().size(), Matchers.equalTo(1)
+        );
+        MatcherAssert.assertThat(
+            first.values().size(), Matchers.equalTo(1)
+        );
+        
+        final YamlMapping palette = first.yamlMapping("palette");
+        MatcherAssert.assertThat(palette.keys().size(), Matchers.is(12));
+        MatcherAssert.assertThat(palette.values().size(), Matchers.is(12));
+        MatcherAssert.assertThat(
+            palette.string("gray"),
+            Matchers.is("'#404040'")
+        );
+        MatcherAssert.assertThat(
+            palette.string("magenta"),
+            Matchers.is("rgb(255, 102, 255)")
+        );
+        
+        final YamlMapping second = sequence.yamlMapping(1);
+        MatcherAssert.assertThat(
+            second.keys().size(), Matchers.equalTo(1)
+        );
+        MatcherAssert.assertThat(
+            second.values().size(), Matchers.equalTo(1)
+        );
+        
+        final YamlMapping workspace = second.yamlMapping("workspace");
+        MatcherAssert.assertThat(workspace.keys().size(), Matchers.is(3));
+        MatcherAssert.assertThat(workspace.values().size(), Matchers.is(3));
+        MatcherAssert.assertThat(
+            workspace.string("background"),
+            Matchers.is("gray")
+        );
+        MatcherAssert.assertThat(
+            workspace.yamlMapping("elements")
+                .yamlMapping("devices")
+                .yamlMapping("pins")
+                .yamlSequence("active")
+                .string(1),
+            Matchers.is("hsl(163, 45%, 100%)")
+        );
+        MatcherAssert.assertThat(
+            workspace.yamlMapping("guides").string("grid"),
+            Matchers.is("stroke rgba(255, 255, 255, 0.3)")
+        );
+    }
+    
     /**
      * A YamlSequence in block style can be read.
      * @throws Exception If something goes wrong.
@@ -180,7 +298,7 @@ public final class RtYamlInputTest {
 
         YamlSequence read = new RtYamlInput(
             new ByteArrayInputStream(
-                "- apples\n- pears\n- peaches".getBytes()
+                "---\n- apples\n- pears\n- peaches".getBytes()
             )
         ).readYamlSequence();
 
diff --git a/src/test/resources/mapping_ignore_directives.yml b/src/test/resources/mapping_ignore_directives.yml
new file mode 100644
index 0000000..e723d35
--- /dev/null
+++ b/src/test/resources/mapping_ignore_directives.yml
@@ -0,0 +1,49 @@
+# At the moment, the parser shouldn't care about directives and marker lines, when
+# reading a YAML mapping or sequence.
+%YAML 1.2
+---
+palette:
+  # The palette is a universal, theme-specific collection of colors.
+  # It serves as the theme's variables, which can be referenced by
+  # $(color) anywhere in the theme, eg.
+  #  wire:
+  #    off: stroke $(light_gray)
+  # It can also be used in JS, using the Draw.paletteColor(col: string)
+  # function.
+
+  # - Grayscale -
+  black: '#303030'
+  gray: '#404040'
+  light_gray: '#484848'
+  white: white
+
+  # - Colors -
+  red: rgb(255, 105, 102)
+  orange: rgb(255, 179, 102)
+  yellow: rgb(255, 255, 102)
+  green: rgb(102, 155, 102)
+  cyan: rgb(102, 230, 255)
+  blue: rgb(102, 102, 255)
+  purple: rgb(189, 102, 255)
+  magenta: rgb(255, 102, 255)
+
+workspace:
+
+  background: gray
+  
+  guides:
+    lines: stroke rgba(255, 255, 255, 0.3)
+    grid: stroke rgba(255, 255, 255, 0.3)
+  
+  elements:
+    devices:
+      pins:
+        inactive: 'fill #c0c0c0'
+        active:
+          - hsl(224, 45%, 100%)
+          - hsl(163, 45%, 100%)
+          - hsl(102, 45%, 100%)
+      wires:
+        inactive: 'stroke #808080'
+        active: activePin
+        creator: stroke rgba(255, 255, 255, 0.125)
\ No newline at end of file
diff --git a/src/test/resources/sequence_ignore_directives.yml b/src/test/resources/sequence_ignore_directives.yml
new file mode 100644
index 0000000..4086a4d
--- /dev/null
+++ b/src/test/resources/sequence_ignore_directives.yml
@@ -0,0 +1,51 @@
+# At the moment, the parser shouldn't care about directives and marker lines, when
+# reading a YAML mapping or sequence.
+%YAML 1.2
+---
+-
+  palette:
+    # The palette is a universal, theme-specific collection of colors.
+    # It serves as the theme's variables, which can be referenced by
+    # $(color) anywhere in the theme, eg.
+    #  wire:
+    #    off: stroke $(light_gray)
+    # It can also be used in JS, using the Draw.paletteColor(col: string)
+    # function.
+
+    # - Grayscale -
+    black: '#303030'
+    gray: '#404040'
+    light_gray: '#484848'
+    white: white
+
+    # - Colors -
+    red: rgb(255, 105, 102)
+    orange: rgb(255, 179, 102)
+    yellow: rgb(255, 255, 102)
+    green: rgb(102, 155, 102)
+    cyan: rgb(102, 230, 255)
+    blue: rgb(102, 102, 255)
+    purple: rgb(189, 102, 255)
+    magenta: rgb(255, 102, 255)
+
+-
+  workspace:
+
+    background: gray
+  
+    guides:
+      lines: stroke rgba(255, 255, 255, 0.3)
+      grid: stroke rgba(255, 255, 255, 0.3)
+  
+    elements:
+      devices:
+        pins:
+          inactive: 'fill #c0c0c0'
+          active:
+            - hsl(224, 45%, 100%)
+            - hsl(163, 45%, 100%)
+            - hsl(102, 45%, 100%)
+        wires:
+          inactive: 'stroke #808080'
+          active: activePin
+          creator: stroke rgba(255, 255, 255, 0.125)
\ No newline at end of file