Search in sources :

Example 1 with HTMLCleanupProcessorImpl

use of org.eclipse.wst.html.core.internal.cleanup.HTMLCleanupProcessorImpl in project webtools.sourceediting by eclipse.

the class TestHTMLCleanupProcessor method testCollapseEmptyTagsHTML.

/**
 * <p><b>TEST:</b> collapsing empty tags in an html document</p>
 */
public void testCollapseEmptyTagsHTML() throws Exception {
    HTMLCleanupProcessorImpl cleanupProcessor = getProcessorForForEmptyTagsTest();
    runTest("test1.html", "test1-expected.html", cleanupProcessor);
}
Also used : HTMLCleanupProcessorImpl(org.eclipse.wst.html.core.internal.cleanup.HTMLCleanupProcessorImpl)

Example 2 with HTMLCleanupProcessorImpl

use of org.eclipse.wst.html.core.internal.cleanup.HTMLCleanupProcessorImpl in project webtools.sourceediting by eclipse.

the class HTMLConverter method cleanupModel.

public void cleanupModel(IDOMModel model) {
    if (model == null)
        return;
    HTMLCleanupProcessorImpl processor = new HTMLCleanupProcessorImpl();
    IStructuredCleanupPreferences pref = processor.getCleanupPreferences();
    // backup options
    boolean compressEmptyElementTags = pref.getCompressEmptyElementTags();
    boolean insertRequiredAttrs = pref.getInsertRequiredAttrs();
    boolean insertMissingTags = pref.getInsertMissingTags();
    boolean quoteAttrValues = pref.getQuoteAttrValues();
    boolean formatSource = pref.getFormatSource();
    int tagNameCase = pref.getTagNameCase();
    int attrNameCase = pref.getAttrNameCase();
    // setup options
    pref.setCompressEmptyElementTags(true);
    pref.setInsertRequiredAttrs(true);
    pref.setInsertMissingTags(true);
    pref.setQuoteAttrValues(true);
    pref.setFormatSource(false);
    if (model.getDocument().isXMLType()) {
        // XHTML
        pref.setTagNameCase(HTMLCorePreferenceNames.LOWER);
        pref.setAttrNameCase(HTMLCorePreferenceNames.LOWER);
    } else {
        pref.setTagNameCase(HTMLCorePreferenceNames.ASIS);
        pref.setAttrNameCase(HTMLCorePreferenceNames.ASIS);
    }
    processor.cleanupModel(model);
    // set back options
    pref.setCompressEmptyElementTags(compressEmptyElementTags);
    pref.setInsertRequiredAttrs(insertRequiredAttrs);
    pref.setInsertMissingTags(insertMissingTags);
    pref.setQuoteAttrValues(quoteAttrValues);
    pref.setFormatSource(formatSource);
    pref.setTagNameCase(tagNameCase);
    pref.setAttrNameCase(attrNameCase);
}
Also used : IStructuredCleanupPreferences(org.eclipse.wst.sse.core.internal.cleanup.IStructuredCleanupPreferences) HTMLCleanupProcessorImpl(org.eclipse.wst.html.core.internal.cleanup.HTMLCleanupProcessorImpl)

Example 3 with HTMLCleanupProcessorImpl

use of org.eclipse.wst.html.core.internal.cleanup.HTMLCleanupProcessorImpl in project webtools.sourceediting by eclipse.

the class TestHTMLCleanupProcessor method getProcessorForForEmptyTagsTest.

/**
 * @return a configured {@link HTMLCleanupProcessorImpl} for testing compressing empty tags
 */
private static HTMLCleanupProcessorImpl getProcessorForForEmptyTagsTest() {
    HTMLCleanupProcessorImpl cleanupProcessor = new HTMLCleanupProcessorImpl();
    cleanupProcessor.getCleanupPreferences().setCompressEmptyElementTags(true);
    cleanupProcessor.getCleanupPreferences().setInsertRequiredAttrs(false);
    cleanupProcessor.getCleanupPreferences().setInsertMissingTags(true);
    cleanupProcessor.getCleanupPreferences().setQuoteAttrValues(false);
    cleanupProcessor.getCleanupPreferences().setFormatSource(false);
    cleanupProcessor.getCleanupPreferences().setConvertEOLCodes(false);
    return cleanupProcessor;
}
Also used : HTMLCleanupProcessorImpl(org.eclipse.wst.html.core.internal.cleanup.HTMLCleanupProcessorImpl)

Example 4 with HTMLCleanupProcessorImpl

use of org.eclipse.wst.html.core.internal.cleanup.HTMLCleanupProcessorImpl in project webtools.sourceediting by eclipse.

the class TestHTMLCleanupProcessor method testCollapseEmptyTagsXHTML.

/**
 * <p><b>TEST:</b> collapsing empty tags in an xhtml document</p>
 */
public void testCollapseEmptyTagsXHTML() throws Exception {
    HTMLCleanupProcessorImpl cleanupProcessor = getProcessorForForEmptyTagsTest();
    runTest("test2.html", "test2-expected.html", cleanupProcessor);
}
Also used : HTMLCleanupProcessorImpl(org.eclipse.wst.html.core.internal.cleanup.HTMLCleanupProcessorImpl)

Aggregations

HTMLCleanupProcessorImpl (org.eclipse.wst.html.core.internal.cleanup.HTMLCleanupProcessorImpl)4 IStructuredCleanupPreferences (org.eclipse.wst.sse.core.internal.cleanup.IStructuredCleanupPreferences)1