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

MDX -> Apple: extract css file #390

Open
sonerfromnurland opened this issue Oct 1, 2022 · 7 comments
Open

MDX -> Apple: extract css file #390

sonerfromnurland opened this issue Oct 1, 2022 · 7 comments

Comments

@sonerfromnurland
Copy link

sonerfromnurland commented Oct 1, 2022

Doesn't a .mdx/.mdd file contain ".css" file? When I want to convert it to AppleDict format, always extract same css file. For example, this link(cambridge) and this link(collins) extract same css file. The css file is useless because it doesn't actually contain codes to make preview beautiful. What point am I missing? I have also tried other dicts that is of .mdx file format. But they look pretty ugly since there is no a suitable css file.

Both file extracts the following css,


@charset "UTF-8";
@namespace d url(http://www.apple.com/DTDs/DictionaryService-1.0.rng);

@media (prefers-color-scheme: dark) {
	html {
		-apple-color-filter: apple-invert-lightness();
	}

	img {
		filter: invert(0%);
	}
}

d|entry {
}

h1	{
	font-size: 150%;
}

h3	{
	font-size: 100%;
}

.ex, .m, .m0, .m1, .m2, .m3, .m4, .m5, .m6, .m7, .m8, .m9 {
	display: block;
}

.m  { margin-left: 0em; }
.m0 { margin-left: 0em; }
.m1 { margin-left: 1em; }
.m2 { margin-left: 2em; }
.m3 { margin-left: 3em; }
.m4 { margin-left: 4em; }
.m5 { margin-left: 5em; }
.m6 { margin-left: 6em; }
.m7 { margin-left: 7em; }
.m8 { margin-left: 8em; }
.m9 { margin-left: 9em; }

.ex + br,
.k + br { display: none; }

.c {
	color: green;
}

.p {
	font-style: italic;
	color: green;
}

.ex {
	color: #666;
}

.u {
	text-decoration: underline;
}

/* xdxf support */
.k {
	color: black;
	font-weight: bold;
	display: block;
}
.tr {
	color: black;
}
.abr {
	color: #008000;
	font-style: italic;
}
.hideextra .extra {
	display: none;
}
.stress {
	color: #FF0000;
}
.kref {
	color: #000080;
	text-decoration: none;
}
.pr {
	color: #000080;
	white-space: nowrap;
	text-decoration: none;
	overflow: hidden;
	text-overflow: ellipsis;
	padding-right: 1ex;
}

@ilius
Copy link
Owner

ilius commented Oct 1, 2022

What's the name of css file?

@sonerfromnurland
Copy link
Author

what we wrote as output file, that is it while using this tool.

@ilius
Copy link
Owner

ilius commented Nov 12, 2022

Apple Dict writer creates it's own css file to make it look nice in Apple Dict, because most input formats don't have a css file.
In this case, to use the css file from input MDD, you have to first extract it.
So try following steps:

  • Run pyglossary CALD4.mdx CALD4.txt
  • Look at CALD4.txt_res directory and find the name of css file
  • Run pyglossary CALD4.mdx CALD4.apple --write-options=css=CALD4.txt_res/FILE.css, giving your css file name at the end.

@ilius
Copy link
Owner

ilius commented Nov 12, 2022

The reason I'm not sure about making this automatic is that MDD file may contain several css files, each one used in some entries, and we don't keep track of their usage.

Please let's see if this works.
Perhaps we can make it a bit easier later.

@ilius ilius changed the title Extraction ".css" files form .mdx/.mdd files MDX -> Apple: extract ".css" files form .mdx/.mdd files Nov 25, 2022
@ilius ilius changed the title MDX -> Apple: extract ".css" files form .mdx/.mdd files MDX -> Apple: extract css file Nov 25, 2022
@Archie-King
Copy link

Archie-King commented Sep 11, 2023

@ilius When I use ui-gtk3 or command line to convert .mdx to apple-dictionary, there are some issues with splitting words. Some sentences have no spaces between words, which are normally in other programs using .mdx files. How to solve it?

image

@ilius
Copy link
Owner

ilius commented Nov 25, 2024

Which glossary is this?
Can't find it in either one you attached.

@ilius
Copy link
Owner

ilius commented Nov 25, 2024

It shows fine with AyanDict when I convert Collins to StarDict.
ayandict-collins-textile-390

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants