Commit 99ba0b38 authored by Mayra Cabrera's avatar Mayra Cabrera

Merge branch 'remove_partial_anchors_allowance' into 'master'

Follow-up for product suffixes removal RUN AS-IF-FOSS

See merge request gitlab-org/gitlab!39850
parents 88531a6a a8c5858c
...@@ -45,7 +45,6 @@ docs lint: ...@@ -45,7 +45,6 @@ docs lint:
image: "registry.gitlab.com/gitlab-org/gitlab-docs/lint:vale-2.3.4-markdownlint-0.23.2" image: "registry.gitlab.com/gitlab-org/gitlab-docs/lint:vale-2.3.4-markdownlint-0.23.2"
stage: test stage: test
needs: [] needs: []
allow_failure: true
script: script:
- scripts/lint-doc.sh - scripts/lint-doc.sh
# Prepare docs for build # Prepare docs for build
......
...@@ -1656,7 +1656,7 @@ job: ...@@ -1656,7 +1656,7 @@ job:
- /^release/.*$/@gitlab-org/gitlab - /^release/.*$/@gitlab-org/gitlab
``` ```
The above example will run `job` for all branches on `gitlab-org/gitlab`, The above example runs `job` for all branches on `gitlab-org/gitlab`,
except `master` and those with names prefixed with `release/`. except `master` and those with names prefixed with `release/`.
If a job does not have an `only` rule, `only: ['branches', 'tags']` is set by If a job does not have an `only` rule, `only: ['branches', 'tags']` is set by
......
...@@ -92,8 +92,7 @@ module HamlLint ...@@ -92,8 +92,7 @@ module HamlLint
File.open(path_to_file).any? do |line| File.open(path_to_file).any? do |line|
result = line.match(MARKDOWN_HEADER) result = line.match(MARKDOWN_HEADER)
# TODO:Do an exact match for anchors (Follow-up https://gitlab.com/gitlab-org/gitlab/-/merge_requests/39850) string_to_anchor(result[:header]) == anchor if result
anchor.start_with?(string_to_anchor(result[:header].delete('*'))) if result
end end
end end
end end
......
...@@ -4,7 +4,7 @@ module Gitlab ...@@ -4,7 +4,7 @@ module Gitlab
module Utils module Utils
module Markdown module Markdown
PUNCTUATION_REGEXP = /[^\p{Word}\- ]/u.freeze PUNCTUATION_REGEXP = /[^\p{Word}\- ]/u.freeze
PRODUCT_SUFFIX = /\s*\((core|starter|premium|ultimate)(\s+only)?\)/.freeze PRODUCT_SUFFIX = /\s*\**\((core|starter|premium|ultimate)(\s+only)?\)\**/.freeze
def string_to_anchor(string) def string_to_anchor(string)
string string
......
...@@ -20,13 +20,6 @@ RSpec.describe HamlLint::Linter::DocumentationLinks do ...@@ -20,13 +20,6 @@ RSpec.describe HamlLint::Linter::DocumentationLinks do
it { is_expected.not_to report_lint } it { is_expected.not_to report_lint }
end end
# TODO: Remove me after https://gitlab.com/gitlab-org/gitlab/-/merge_requests/39715 is merged
context 'when link_to points to the existing file with partially matching anchor' do
let(:haml) { "= link_to 'Description', help_page_path('README.md', anchor: 'overview-premium'), target: '_blank'" }
it { is_expected.not_to report_lint }
end
context 'when link_to points to the existing file path without .md extension' do context 'when link_to points to the existing file path without .md extension' do
let(:haml) { "= link_to 'Description', help_page_path('README')" } let(:haml) { "= link_to 'Description', help_page_path('README')" }
......
...@@ -66,6 +66,22 @@ RSpec.describe Gitlab::Utils::Markdown do ...@@ -66,6 +66,22 @@ RSpec.describe Gitlab::Utils::Markdown do
is_expected.to eq 'my-header' is_expected.to eq 'my-header'
end end
end end
context 'with "*" around a product suffix' do
let(:string) { 'My Header **(STARTER)**' }
it 'ignores a product suffix' do
is_expected.to eq 'my-header'
end
end
context 'with "*" around a product suffix and only modifier' do
let(:string) { 'My Header **(STARTER ONLY)**' }
it 'ignores a product suffix' do
is_expected.to eq 'my-header'
end
end
end end
context 'when string is empty' do context 'when string is empty' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment