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


##########
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:
   I found a problem while experimenting with this. I tried to set the headings 
all to a "fancy" font, so that I can recognize the change. See this preview:
   
   <img width="419" height="233" alt="Image" 
src="https://github.com/user-attachments/assets/3794419d-6ef3-485f-a778-f20fef037afa";
 />
   
   The preview shows, that H1 is changed, but H2 remains the base font. That is 
in contrast to the configuration:
   
   <img width="799" height="227" alt="Image" 
src="https://github.com/user-attachments/assets/9156da72-37bc-4cc4-a343-949f775d52af";
 />
   
   <img width="871" height="633" alt="Image" 
src="https://github.com/user-attachments/assets/03328d22-0d79-4a7b-bf7d-e13f13a4eb1e";
 />
   
   The configuration (`FontAndColors.xml`) indicates that H2 should inherit 
from H1 and in the settings this is correctly recognized (see final "Font" 
setting for H2).
   
   I think the problem is that the attribute application here does not follow 
the inheritance tree.



-- 
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