matthiasblaesing commented on code in PR #9240:
URL: https://github.com/apache/netbeans/pull/9240#discussion_r2941910131


##########
ide/markdown/src/org/netbeans/modules/markdown/utils/StyleUtils.java:
##########
@@ -0,0 +1,182 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.netbeans.modules.markdown.utils;
+
+import java.awt.Color;
+import java.util.Enumeration;
+import java.util.Iterator;
+import java.util.Map;
+import javax.swing.text.AttributeSet;
+import javax.swing.text.StyleConstants;
+import javax.swing.text.html.StyleSheet;
+import org.netbeans.api.editor.mimelookup.MimeLookup;
+import org.netbeans.api.editor.mimelookup.MimePath;
+import org.netbeans.modules.editor.settings.storage.api.EditorSettings;
+import org.netbeans.api.editor.settings.FontColorSettings;
+import 
org.netbeans.modules.editor.settings.storage.api.FontColorSettingsFactory;
+import static 
org.netbeans.modules.markdown.MarkdownViewerElement.MIME_TYPE_PREVIEW;
+import org.openide.util.NbBundle;
+
+/**
+ *
+ * @author bhaidu
+ */
+public class StyleUtils {
+
+    private static final Map<String, String> fontConfig2tagMapping = 
Map.ofEntries(
+        Map.entry("body", "body"), // NOI18N
+        Map.entry("code", "code"), // NOI18N
+        Map.entry("pre", "pre"), // NOI18N
+        Map.entry("blockquote", "blockquote p"), // NOI18N
+        Map.entry("heading1", "h1, h1 a"), // NOI18N
+        Map.entry("heading2", "h2, h2 a"), // NOI18N
+        Map.entry("heading3", "h3, h3 a"), // NOI18N
+        Map.entry("heading4", "h4, h4 a"), // NOI18N
+        Map.entry("heading5", "h5, h5 a"), // NOI18N
+        Map.entry("heading6", "h6, h6 a") // NOI18N
+    );
+
+    public static void addNbSyles(StyleSheet ss) {
+
+        //main css
+        appendDefaultMarkdownCssRules(ss);
+
+        //coloring & font settings
+        appendColoringCssRulesFromFontConfigs(ss);
+    }
+
+    public static void addRule(StyleSheet ss, AttributeSet attributeSet, 
AttributeSet defaultAttributes) {

Review Comment:
   Ok - lets keep this minimal. Please have a look here:
   
   
https://github.com/matthiasblaesing/netbeans/commit/8a7120505528f39c5f36bafd5be3c24900625a35
   
   There are two different things in here:
   
   - Remove the inheritance marker. I had a prototype for inheritance, but that 
is even more complex and brings more questions than answers. For real 
inheritance you'd need to gather all `AttributeSets` that are chained using the 
`default` attribute and create a composite set (there is a helper in the editor 
settings for that).
   - Simplify the `StyleUtils`. With the current implementation `addRule` will 
be invoked for each attribute name, in effect adding the AttributeSet multiple 
times. I removed the iteration over the attributes as there is alreay a guard 
inside `addRule`.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists

Reply via email to