Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
ots-doctools
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ots
ots-doctools
Commits
e13a04ad
Commit
e13a04ad
authored
5 years ago
by
James Vasile
Browse files
Options
Downloads
Patches
Plain Diff
Allow user override of ref regex
parent
a2ddc01f
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
pipeline/plugins/60_clean_refs.py
+8
-3
8 additions, 3 deletions
pipeline/plugins/60_clean_refs.py
with
8 additions
and
3 deletions
pipeline/plugins/60_clean_refs.py
+
8
−
3
View file @
e13a04ad
#!/usr/bin/env python3
"""
This plugin removes \S*ref:[0-9a-f]\S* from the output in an
attempt to remove oref tags from the text.
"""
This plugin removes refs from the output so we can ref and deref
without it showing in the final doc.
By default, we remove ref:[0-9a-f]+ with surrounding parentheses and
brackets. You can set ref_regex in the YAML head of the doc to
override.
"""
import
os
import
re
...
...
@@ -14,7 +19,7 @@ def run(text, meta):
Returns text with a regex substitution and unchanged META.
"""
pat
=
re
.
compile
(
"
\S
*ref:[0-9a-f]+
\S
*
"
)
pat
=
re
.
compile
(
meta
.
get
(
"
ref_regex
"
,
"
[[(]
*ref:[0-9a-f]+
[])]
*
"
)
)
text
=
pat
.
sub
(
""
,
text
)
return
text
,
meta
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment