I have a desideratum, which is to be able to enter left-aligned (aka 
'left-to-right' or 'LTR') pre-formatted text into a card. The pre-formatting 
should apply regardless of the default alignment of text in that card type. My 
use-case is that I wish to use Mnemosyne to study code snippets, but satisfying 
my desideratum would potentially also be useful for people studying certain 
kinds of poetry or other texts in which the alignment of the columns of 
characters is important. In the case of code snippets, preserving indentation 
and displaying the snippet in a monospaced typeface is important for two 
reasons:

1. it enhances comprehensibility of code snippets during revision, and

2. it more closely matches the appearance of code in real computer programs as 
viewed in text editors or Integrated Development Environments ('IDEs'), 
therefore improving the applicability of the revision performed in Mnemosyne.

Unfortunately, I have not yet found a way to achieve this desideratum in 
Mnemosyne 2.3.6.

Here is my progress so far. Suppose I want to have the following text on the 
front of a card:

def some_fun():
    foo  = 1
    bar  = 2
    bork = 3

As my first attempt, I simply copy and paste the above snippet into the 'Front' 
field of a new 'Front and back' card. By default, however, the resulting card 
front displays each line individually centred, so the desideratum is not 
satisfied by this attempt.

If I go to Settings > Configure Mnemosyne > Card appearance , then I can set 
cards of this type to display their contents left-aligned or right-aligned, but 
neither option preserves the text as entered. For example, left-alignment 
strips leading whitespace, causing the indentation to be lost. So, the 
desideratum is not satisfied by this attempt.

So, I tried surrounding the example above with '<code>' and '</code>' tags. 
Unfortunately, Mnemosyne seems to completely ignore these. So, the desideratum 
is not satisfied by this attempt.

So, I tried surrounding the example above with '<pre>' and '</pre>' tags 
instead. If the card type is set to use right or centred alignment (see above), 
then unfortunately, these tags are effectively ignored by Mnemosyne. So, the 
desideratum is not satisfied by this attempt.

If the card type is set to use left-alignment, and the code snippet is put into 
a 'pre' element (see above), then the leading whitespace is preserved. Yay! But 
now we encounter another problem: the typeface is not monospaced, so the 
alignment in the snippet is not preserved. (Shouldn't any HTML rendering engine 
render 'pre' element contents using a monospaced typeface by default?) So, the 
desideratum is not satisfied by this attempt.

If the card type is set to use left-alignment, and the code snippet is put into 
a 'pre' element, and the card type is set to use a monospaced typeface (via 
Settings > Configure Mnemosyne > Card appearance > Select font , then any Front 
or Back text outside of a 'pre' element becomes monospaced, but unfortunately 
the contents of the 'pre' element remains in a proportional (i.e. 
non-monospace) typeface! So, the desideratum is not satisfied by this attempt.

Next, I attempted several ways of making the contents of the 'pre' element 
monospaced. Sadly, none of them worked. Here is a list of those attempts, which 
were performed singly (i.e. not combined):

- At the top of the card's 'Front' field, add the line, '<style>pre { 
font-family: monospace }</style>'.

- Add a 'style' attribute to the opening 'pre' tag: '<pre style="font-family: 
monospace">'.

- Wrap the 'pre' element in a 'font' element: '<font 
face="freemono"><pre>...</pre></font>'.

- Wrap the 'pre' element contents in a 'font' element: '<pre><font 
face="freemono">...</font></pre>'.

Having made so many attempts without success, I fear that either I have missed 
something terribly obvious, or else Mnemosyne does not currently support my 
desideratum. I would appreciate advice about which of these two possibilities 
is in fact the case.

Many thanks!

Sam

-- 
You received this message because you are subscribed to the Google Groups 
"mnemosyne-proj-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/mnemosyne-proj-users/41870933-c624-4c4b-bc78-7cb39c72e1ef%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to