Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: YAML cssclasses are not added to exported document #421

Open
GreenManSK opened this issue Apr 18, 2024 · 4 comments
Open

[Bug]: YAML cssclasses are not added to exported document #421

GreenManSK opened this issue Apr 18, 2024 · 4 comments
Labels
bug Something isn't working

Comments

@GreenManSK
Copy link

What happened?

Not sure if this is bug or just missing feature but since cssclasses have effect on PDF export I would assume this is bug.
From my testing it seems they are not added to the exported document, causing any styles connected to them to not take effect.

I seen this issue where it seems that it worked before but not currently #307

Reproduction

Add cssclasses property to document such as:

---
cssclasses:
  - center-images
  - center-tables
---

Export document, these css classes are not present on the document.

Last Working Version

Not sure, seems like yes

Version

1.8.01

Operating System

Windows

Obsidian Version

1.5.12

Which browsers can you reproduce this in?

Chrome, Microsoft Edge

Relevant log output

N/A

Additional Info

HTML element in obsidian:
obrazek

Exported HTML element:
obrazek

@GreenManSK GreenManSK added the bug Something isn't working label Apr 18, 2024
@KosmosisDire
Copy link
Owner

Hi, can you please include the debug info from the plugin it will help me to see what settings you are using for the export.

This feature should work, and still does work in my testing in the beta version. I will test it in the 1.8.01 version and let you know if that works for me.

Thanks for the report!

@GreenManSK
Copy link
Author

Here is the debug info.

Log:
[WARNING] 	Creating an RSS feed requires a site url to be set in the export settings.
[WARNING] 	No existing export metadata found. All files will be exported.
[WARNING] 	No existing search index found. All files will be exported.
[WARNING] 	No existing RSS feed found. All files will be exported.
[INFO] 	Closing render window
[WARNING] 	Creating an RSS feed requires a site url to be set in the export settings.
[INFO] 	No old files to delete
[INFO] 	Closing render window


Settings:
	settingsVersion --------- 1.8.01
	makeOfflineCompatible     false
	inlineAssets ------------ false
	includePluginCSS          1 plugins included
	includeSvelteCSS -------- true
	titleProperty             title
	customHeadContentPath ---
	faviconPath              
	documentWidth ----------- 40em
	sidebarWidth              20em
	minOutlineCollapse ------ 2
	startOutlineCollapsed     false
	allowFoldingHeadings ---- true
	allowFoldingLists         true
	allowResizingSidebars --- true
	logLevel                  warning
	minifyHTML -------------- true
	makeNamesWebStyle         true
	onlyExportModified ------ true
	deleteOldFiles            true
	addThemeToggle ---------- true
	addOutline                true
	addFileNav -------------- true
	addSearchBar              true
	addGraphView ------------ true
	addTitle                  true
	addRSSFeed -------------- true
	siteURL                  
	authorName --------------
	vaultTitle                Testing
	exportPreset ------------ website
	openAfterExport           false
	graphAttractionForce ---- 1
	graphLinkLength           10
	graphRepulsionForce ----- 150
	graphCentralForce         3
	graphEdgePruning -------- 100
	graphMinNodeSize          3
	graphMaxNodeSize -------- 7
	showDefaultTreeIcons      false
	emojiStyle -------------- Native
	defaultFileIcon           lucide//file
	defaultFolderIcon ------- lucide//folder
	defaultMediaIcon          lucide//file-image
	exportPath -------------- C:\\\\Users\\lukas\\OneDrive\\Downloads\\test\\web
	filesToExport             1


Enabled Plugins:
	Webpage HTML Export

I get this even in freshly created vault with just the plugin installed. Attaching zip with the vault if it helps.
Testing.zip

@GreenManSK
Copy link
Author

I tried to do a bit of digging and I think the issue is with how the page is generated from the document. Obsidian puts these css classes on .markdown-preview-view element, but in render-api.ts on line 374 this element gets created and only receives content from the real preview element.

I do not know much about Obsidian development or why this was done this way, but by updating it to this:

let newMarkdownEl = document.body.createDiv({ cls: renderer.previewEl.className/*"markdown-preview-view markdown-rendered"*/ });

I was able to fix the issue. This of course also adds many classes that are not based on the YAML cssclasses which could cause issues. Sadly I do not know enough about this.

@KosmosisDire
Copy link
Owner

Hi thanks, I can verify that this bug exists in 1.8.01 and that it is fixed in version 1.8.1-2b (which is the beta version). So this fix will come to stable in the next release

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Development

No branches or pull requests

2 participants