Apply custom class to string
See original GitHub issueI’m submitting a…
- Question
Reproduction steps
I’m looking the way to highlight some text in the editor, for example when I write ???category
I want to apply some CSS style to that part of the text, it’s possible ?
Thank you!
EDIT:
Here some code for what I want to do, for example if I write &Hello
the text parsed and styled to
<span class="cm-formatting cm-my-style1">&</span>
<span class="cm-my-style2">Hello</span>
Issue Analytics
- State:
- Created 5 years ago
- Comments:6
Top Results From Across the Web
How to create a custom string representation for a class object?
Use __str__ if you mean a readable stringification, use __repr__ for unambiguous representations. Edit: Python 3 Version. class MC(type): def __ ...
Read more >How to create a custom String class in C++ with basic ...
In this article, we will create our custom string class which will have the same functionality as the existing string class.
Read more >Python string formatting with custom classes | by Jacob Unna
In this article we will see how you can use custom classes to do cool stuff with .format() . Format options. A useful...
Read more >Customizing the string representation of your objects
You'll almost always just want to customize one of Python's two string representations (repr, the programmer readable-one).
Read more >Want Proper String Representations in Custom Python ...
Use These 2 Built-in Methods ... To define the proper string representations of a custom class, we need to override two special methods: ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
You could do that with the CodeMirror API (you can access the codeMirror object with
easyMDE.codemirror
).First, look for your word with
cm.findWordAt()
:Then, mark this section with a class with
doc.markText
:Note that if you only want to add CSS to this text, you don’t really need to add a class, because
markext()
has also a css configuration option, so you can do it directly:@dignajar were you able to get the highlighting to work? I have an event handler for
change
events that should be adding in highlights, but am unable to see them. it appears to be at least somewhat working since I can query for all of the marks and they show up. Any ideas?