gnu-regexp dependency in simplyhtml

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

gnu-regexp dependency in simplyhtml

Felix Natter
Administrator
hello devs,

simplyhtml only requires the old gnu-regexp library in
com.lightdev.app.shtm.SHTMLEditorPane.setText(String),
for fixing this bug in java4:
http://bugs.java.com/bugdatabase/view_bug.do?bug_id=4799813

I would like to move this to the standard java regex api.

here is the method:
    /**
       * Convenience method for setting the document text
       * contains hack around JDK bug 4799813
       * see http://developer.java.sun.com/developer/bugParade/bugs/4799813.html
       * regression in 1.4.x, to be fixed in 1.5
       * When setting the text to be "& footext", it becomes "&footext" (space disappears)
       * same ocurrs for "</a> &amp;", it becomes "</a>&amp;" (space disappears)
       * with the hack it now does not occur anymore.
       * @param sText the html-text of the document
       */
    public void setText(String sText) {
        try {
            if (System.getProperty("java.version").substring(0, 3).equals("1.4")) {
                if (pattern1 == null) {
                    pattern1 = new gnu.regexp.RE("(&\\w+;|&#\\d+;)(\\s| | )(?=<|&\\w+;|&#\\d+;)");
                }
                sText = pattern1.substituteAll(sText, "$1 $3");
                if (pattern2 == null) {
                    pattern2 = new gnu.regexp.RE("<(/[^>])>(\\s| | |\\n\\s+)(?! )(&\\w+;|&#\\d+;)");
                }
                sText = pattern2.substituteAll(sText, "<$1> $3$4");
            }
        }
        catch (final gnu.regexp.REException ree) {
            ree.printStackTrace();
        }
        final SHTMLDocument doc = (SHTMLDocument) getDocument();
        doc.startCompoundEdit();
        if (sText == null || sText.equals("")) {
            sText = "<html><body><p></p></body></html>";
        }
        doc.putProperty(SHTMLDocument.AdditionalComments, null);
        super.setText(sText);
        setCaretPosition(0);
        doc.endCompoundEdit();
        if (OLD_JAVA_VERSION) {
            SHTMLPanelImpl.getOwnerSHTMLPanel(this).purgeUndos();
        }
    }

--> since the block that uses pattern1/pattern2 (the only usage of gnu-regexp in simplyhtml)
is limited to java 1.4, I will just drop the block.

Any objections?

Cheers and Best Regards,
Felix
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: gnu-regexp dependency in simplyhtml

Dimitry Polivaev
Administrator
> I would like to move this to the standard java regex api.

+1 if it works

Are you going to increase the version number?

Regards, Dimitry

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: gnu-regexp dependency in simplyhtml

Felix Natter
Administrator
"Dimitry Polivaev [via Freeplane Developer]"
<[hidden email]> writes:

>> I would like to move this to the standard java regex api.
>
> +1 if it works

Since I am just removing a block for java4:

if (System.getProperty("java.version").substring(0, 3).equals("1.4")) {
.... }

I think this is safe.

> Are you going to increase the version number?

Sure, I will make a 0.16.16 release and pull that in freeplane.

Cheers and Best Regards,
--
Felix Natter
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: gnu-regexp dependency in simplyhtml

Felix Natter
Administrator
hello Dimitry,

I just looked at the new simplyhtml (with mnemonicsetter-0.3): I don't see mnemonics for all menu items.
Is that only activated when using simplyhtml from freeplane?

Thanks and Best Regards,
Felix
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: gnu-regexp dependency in simplyhtml

Dimitry Polivaev
Administrator
I believe it should be active always. However if all letters in the item
name are already used no mnemonics can be assigned. Therefore items
without accelerators are processed first.

Does it explain your observations?

Regards,
Dimitry

> I just looked at the new simplyhtml (with mnemonicsetter-0.3): I don't
> see mnemonics for all menu items.
> Is that only activated when using simplyhtml from freeplane?

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: gnu-regexp dependency in simplyhtml

Felix Natter
Administrator
"Dimitry Polivaev [via Freeplane Developer]"
<[hidden email]> writes:

> I believe it should be active always. However if all letters in the item
> name are already used no mnemonics can be assigned. Therefore items
> without accelerators are processed first.
>
> Does it explain your observations?

My fault: I was looking at accelerators, not mnemonics.
Mnemonics are there :-)

I just tried to upload to bintray:
BINTRAY_USER=fnatter
BINTRAY_KEY=<my password>

$ gradle bintrayUpload

Execution failed for task ':bintrayUpload'.
> Could not create version '0.16.16': HTTP/1.1 401 Unauthorized
> [message:This resource requires authentication]

--> do you need to assign me to the project / give me more rights?

BTW: We should monitor this bug:
  https://sourceforge.net/p/freeplane/discussion/758437/thread/31090933/

BTW2: Could you please add a description on github?
  https://github.com/dpolivaev/mnemonicsetter

Cheers and Best Regards,
--
Felix Natter
Loading...