Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New Feature: Export Explanation to plain text for checking in with code base #1007

Closed
bluerv opened this issue Jun 4, 2018 · 4 comments
Closed

Comments

@bluerv
Copy link

bluerv commented Jun 4, 2018

The Explanation area is very nice for detailing what a particular expression is doing. I attempted to copy/paste that into my code as comments, but it made an unholy mess.

What would be useful is an export button that converts the html into a plain text equivalent (as close as is reasonable... text is only text after all) so that it can be quickly copy/pasted into a code base for future readers (so they don't go "what the heck is this???")

Example of copy/paste:

/
(?'SortOrder'[+-])(?'FindType'[tn])\((?'FindName'[^)]*)\),?
/
gm
Named Capture Group SortOrder (?'SortOrder'[+-])
Match a single character present in the list below [+-]
+- matches a single character in the list +- (case sensitive)
Named Capture Group FindType (?'FindType'[tn])
Match a single character present in the list below [tn]
tn matches a single character in the list tn (case sensitive)
\( matches the character ( literally (case sensitive)
Named Capture Group FindName (?'FindName'[^)]*)
Match a single character not present in the list below [^)]*
* Quantifier — Matches between zero and unlimited times, as many times as possible, giving back as needed (greedy)
) matches the character ) literally (case sensitive)
\) matches the character ) literally (case sensitive)
,? matches the character , literally (case sensitive)
? Quantifier — Matches between zero and one times, as many times as possible, giving back as needed (greedy)
Global pattern flags
g modifier: global. All matches (don't return after first match)
m modifier: multi line. Causes ^ and $ to match the begin/end of each line (not only begin/end of string)

What would be nice:

- / (?'SortOrder'[+-])(?'FindType'[tn])\((?'FindName'[^)]*)\),? / gm
-- Named Capture Group SortOrder (?'SortOrder'[+-])
--- Match a single character present in the list below [+-]
---- +- matches a single character in the list +- (case sensitive)
-- Named Capture Group FindType (?'FindType'[tn])
--- Match a single character present in the list below [tn]
---- tn matches a single character in the list tn (case sensitive)
- \( matches the character ( literally (case sensitive)
-- Named Capture Group FindName (?'FindName'[^)]*)
--- Match a single character not present in the list below [^)]*
---- * Quantifier — Matches between zero and unlimited times, as many times as possible, giving back as needed (greedy)
---- ) matches the character ) literally (case sensitive)
- \) matches the character ) literally (case sensitive)
-- ,? matches the character , literally (case sensitive)
--- ? Quantifier — Matches between zero and one times, as many times as possible, giving back as needed (greedy)
-- Global pattern flags
--- g modifier: global. All matches (don't return after first match)
--- m modifier: multi line. Causes ^ and $ to match the begin/end of each line (not only begin/end of string)
@firasdib
Copy link
Owner

This is a good idea, but the tree is currently generated in a way that makes this difficult without re-writing.

@TWiStErRob
Copy link
Collaborator

Adding those dashes (or other indentation helper) as invisible text (0.1pt) would make it copyable, but not change it visually. This would make the change smaller and achieve the effect wanted.

@TWiStErRob
Copy link
Collaborator

@bluerv consider a regex101 permalink to the regex as an alternative

@firasdib
Copy link
Owner

I've looked into this and I don't think there is a clear and simple solution for it, without a rewrite.

Unfortunately, you'll have to resort to permalinks or copy/paste with custom mods.

If anyone can write a dom-parser that'll just grab the html and convert it to a string, we could perhaps use that, but its not a very clean solution

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants