i’m using CKEditor to allow the user to input text into an asp page coded in c# which outputs some bible texts, now i wanna add a function which lets the user to key in some kinda string which i will detect and replace with some text from the bible, for example, if i enter into the text editor (as an example, with ~~~ as a special sequence of characters which i use to identify special codes/strings)
today is a happy day, i learnt this: ~~~1 John 4:7~~~.
the codebehind should be able to detect the ~~~ in front and at the back of the “1 John 4:7” string, and be able to know that this can be looked up and uses the “1 John 4:7” string to look up a data structure (I’m thinking using a hash or dictionary or linked list) the output on the page may be something like this
today is a happy day, i learnt this: “Beloved, let us love one another, for love is from God.”
i’m able to get this done using a normal text box, but if we have a wysiwyg editor, there are alot of tags added in the background, and if i wanna add color to the string, it’ll complicate the string even more, since the editor may not highlight the whole string from the beginning ~~~ to the end of the ~~~ at the back. i may end up with a string like this (the source of the text in the ckeditor)
<p> <span class="text 1John-4-7" id="en-KJ21-30580">~<span style="background-color: #ffff00">~~</span><strong><span style="background-color: #ffff00">1 Jo<u>hn </u><em>4:7</em></span></strong><span style="background-color: #ffff00">~~~</span></span></p>
so instead of a simple string like this ~~~1 John 4:7~~~ , we have a much longer string with a lot of formatting (which is expected since i wanna be able to add text with formatting in the editor), and the word John and the “~~~” sequence is split up in between tags. (because the string has been highlighted partially, in which case i should use the first color that appears, for the whole special string, or just ignore all tags in between the whole string for simplicity (meaning the looked up text will only adopt the formatting that enclosed the ~~~ special string / code ~~~)
it’ll be great if we can have the whole string ~~~1 John 4:7~~~ as an atomic string (i mean as a continuous string that doesn’t change in the editor), but this may not be the case, so i wanna ask, how should i go about doing this, so that i can allow the user to enter text freely in the editor, and yet have the asp page have the ability to detect that the user keyed in a special string / code which it can try to look up, when a sequence of special characters (in this case ~~~) is used to enclose it.
Thank you very much for reading and good day to you all.
I see two solutions.