diff --git a/internal/marker/marker.go b/internal/marker/marker.go index 7d3f2b8..bd5a4fe 100644 --- a/internal/marker/marker.go +++ b/internal/marker/marker.go @@ -139,7 +139,7 @@ func processIndentOption(marker *Marker, match *RawMarker) error { case "extra": marker.Indentation = &Indentation{Mode: ExtraIndentation} case "align": - markerIndentation := len(match.PrecedingIndentation) - len(strings.TrimLeft(match.PrecedingIndentation, " ")) // Naïve count + markerIndentation := len(match.PrecedingIndentation) marker.Indentation = &Indentation{ Mode: AlignIndentation, MarkerIndentation: markerIndentation, diff --git a/internal/marker/marker_regex.go b/internal/marker/marker_regex.go index 282ea25..d09ed17 100644 --- a/internal/marker/marker_regex.go +++ b/internal/marker/marker_regex.go @@ -10,7 +10,7 @@ var ( ImporterMarkerMarkdown = `` // ImporterMarkerYAML is the annotation used for importer to find match. - ImporterMarkerYAML = `(?P\s*)# == (imptr|import|importer|i): (?P\S+) \/ (?Pbegin|end)(?P.*) ==` + ImporterMarkerYAML = `(?P.*)# == (imptr|import|importer|i): (?P\S+) \/ (?Pbegin|end)(?P.*) ==` // OptionFilePathIndicator is the pattern used for parsing Importer file options. OptionFilePathIndicator = `from: (?P\S+)\s*\#(?P[0-9a-zA-Z,-_\~]+)\s?` diff --git a/internal/marker/marker_test.go b/internal/marker/marker_test.go index e1b2a56..19c36e3 100644 --- a/internal/marker/marker_test.go +++ b/internal/marker/marker_test.go @@ -159,7 +159,7 @@ func TestNewMarker(t *testing.T) { IsEndFound: true, LineToInsertAt: 3, Options: "from: ./abc.yaml#[from-exporter-marker] indent: align", - PrecedingIndentation: " ", + PrecedingIndentation: " - ", // As if yaml list input is used for indentation }, want: &marker.Marker{ Name: "simple-marker", diff --git a/testdata/yaml/align-with-exporter-before.yaml b/testdata/yaml/align-with-exporter-before.yaml index 7e54359..3039415 100644 --- a/testdata/yaml/align-with-exporter-before.yaml +++ b/testdata/yaml/align-with-exporter-before.yaml @@ -7,11 +7,11 @@ data: indentation: for: demo: - # == importer: abc-tree / begin from: ./snippet-with-exporter.yaml#[long-tree] indent: align == - anything: here - would: be - purged: by Importer - # == importer: abc-tree / end == + - # == importer: abc-tree / begin from: ./snippet-with-exporter.yaml#[long-tree] indent: align == + anything: here + would: be + purged: by Importer + # == importer: abc-tree / end == some-data: description: | diff --git a/testdata/yaml/align-with-exporter-purged.yaml b/testdata/yaml/align-with-exporter-purged.yaml index 0fa1e51..a01fc61 100644 --- a/testdata/yaml/align-with-exporter-purged.yaml +++ b/testdata/yaml/align-with-exporter-purged.yaml @@ -7,8 +7,8 @@ data: indentation: for: demo: - # == importer: abc-tree / begin from: ./snippet-with-exporter.yaml#[long-tree] indent: align == - # == importer: abc-tree / end == + - # == importer: abc-tree / begin from: ./snippet-with-exporter.yaml#[long-tree] indent: align == + # == importer: abc-tree / end == some-data: description: | diff --git a/testdata/yaml/align-with-exporter-updated.yaml b/testdata/yaml/align-with-exporter-updated.yaml index 26ac31c..aec0771 100644 --- a/testdata/yaml/align-with-exporter-updated.yaml +++ b/testdata/yaml/align-with-exporter-updated.yaml @@ -7,19 +7,19 @@ data: indentation: for: demo: - # == importer: abc-tree / begin from: ./snippet-with-exporter.yaml#[long-tree] indent: align == - a: - b: - c: - d: - e: - f: - g: - h: - i: - j: - k: {} - # == importer: abc-tree / end == + - # == importer: abc-tree / begin from: ./snippet-with-exporter.yaml#[long-tree] indent: align == + a: + b: + c: + d: + e: + f: + g: + h: + i: + j: + k: {} + # == importer: abc-tree / end == some-data: description: |