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

Add app/choice functionality #3

Open
annplaksin opened this issue Aug 16, 2022 · 2 comments
Open

Add app/choice functionality #3

annplaksin opened this issue Aug 16, 2022 · 2 comments
Labels
enhancement New feature or request

Comments

@annplaksin
Copy link
Contributor

As already mentioned but I almost forgot to write the promised issue, here it is:
One very useful function might be to help users add editorial markup. Especially beginners are struggling with adding editorial markup. mei-friend might be able to help with providing standard templates (reduces accidental typos etc.).

A user might select a certain portion of the MEI file and then ask for surrounding it with an <app> element while the selection will be put into the <lem>, like:

<note pname="a" oct="4" dur="8">
    <refrain>
        <syl wordpos="t">rah!</syl>
    </refrain>
</note>
<note pname="g" oct="4" dur="8">
    <refrain>
        <syl>and</syl>
    </refrain>
</note>

... becomes ...

<app>
    <lem>
        <note pname="a" oct="4" dur="8">
            <refrain>
                <syl wordpos="t">rah!</syl>
            </refrain>
        </note>
        <note pname="g" oct="4" dur="8">
            <refrain>
                <syl>and</syl>
            </refrain>
        </note>
    </lem>
    <rdg>
       <!-- add reading here -->
    </rdg>
</app>

Or ask where the selection should be put...
If useful, that feature might be as well expanded for common cases of <choice> etc.

Of course, this will lead quickly to some general UI-related questions like: Should empty @source attributes be added automatically or not?
Please, consider it more as a suggestion than a request.

@wergo wergo added the enhancement New feature or request label Feb 15, 2023
@o-sapov
Copy link

o-sapov commented Mar 14, 2023

I'd like to add few ideas for this request as on the oXygen side I've implemented a similar functionality using the code templates.
For instance, this code

<note accid.ges="s" doxml.id="d28e114" dur="8" oct="4" pname="f" tstamp="3" xml:id="note_3495"/>
<note accid.ges="s" doxml.id="d28e117" dur="8" oct="4" pname="f" tstamp="3.5" xml:id="note_3501"/>

becomes this

Click to see the snippet

<app xml:id="app_hrd_pzr_5wb">
  <lem source="#source_1" xml:id="lem_pgf_pzr_5wb">
    <note accid.ges="s" doxml.id="d28e114" dur="8" oct="4" pname="f" tstamp="3" xml:id="note_3495a"/>
    <note accid.ges="s" doxml.id="d28e117" dur="8" oct="4" pname="f" tstamp="3.5" xml:id="note_3501a"/>
  </lem>
  <rdg source="#source_1" xml:id="rdg_zfg_pzr_5wb">
    <note accid.ges="s" doxml.id="d28e114" dur="8" oct="4" pname="f" tstamp="3" xml:id="note_3495b"/>
    <note accid.ges="s" doxml.id="d28e117" dur="8" oct="4" pname="f" tstamp="3.5" xml:id="note_3501b"/>
  </rdg>
</app>

A prompt asks for @source values both for <lem> and <rdg> :

image

Note also the following:

  • automatical adding of xml:ids for app, lem and rdg
  • selected elements are doubled, but their @xml:ids get suffixes a and b. This might be optional, but in my experience it could be useful, as in most cases the elements are copied anyway first.

You may want to check it in oXygen (Preferences > Editor > Content completion > Code templates > New):

Click to see the snippet

<app xml:id="app_${id}">
  <lem source="${ask('Source(s) of lem? (Type if multiple)', editable_combobox, ('#source_1':'#source_1';'#source_2':'#source_2';'#source_3':'#source_3'), '#source_1')}" xml:id="lem_${id}">
    ${xpath_eval(

    let $node := parse-xml-fragment('${selection}')/node(),
    $string := serialize($node),
    $pattern := '(<.*?xml:id=")(.*?)(".*?>)',
      $replacement := '$1$2a$3'
      return
      replace($string, $pattern,$replacement)
      )}
  </lem>
  <rdg source="${ask('Source(s) of rdg? (Type if multiple)', editable_combobox, ('#source_1':'#source_1';'#source_2':'#source_2';'#source_3':'#source_3'), '#source_1')}" xml:id="rdg_${id}">
    ${xpath_eval(

    let $node := parse-xml-fragment('${selection}')/node(),
    $string := serialize($node),
    $pattern := '(<.*?xml:id=")(.*?)(".*?>)',
      $replacement := '$1$2b$3'
      return
      replace($string, $pattern,$replacement)
      )}${caret}
  </rdg>
</app>

@o-sapov
Copy link

o-sapov commented Mar 14, 2023

<choice> is very similar, but in this case various combinations of descendants are possible. For instance:

corr-orig

<choice xml:id="choice_pvn_sbs_5wb">
  <corr resp="#NMA-editors" xml:id="corr_ml5_sbs_5wb">
    <note accid.ges="s" doxml.id="d28e106" dur="8" oct="4" pname="f" tstamp="1" xml:id="note_3462a"/>
    <note accid.ges="s" doxml.id="d28e108" dur="8" oct="4" pname="f" tstamp="1.5" xml:id="note_3468a"/>
  </corr>
  <orig xml:id="orig_vl5_sbs_5wb">
    <note accid.ges="s" doxml.id="d28e106" dur="8" oct="4" pname="f" tstamp="1" xml:id="note_3462b"/>
    <note accid.ges="s" doxml.id="d28e108" dur="8" oct="4" pname="f" tstamp="1.5" xml:id="note_3468b"/>
  </orig>
</choice>

reg-orig

<choice xml:id="choice_wdn_wbs_5wb">
  <reg resp="#DME-editors" type="#editorial_normalization" xml:id="reg_jks_wbs_5wb">
    <note accid.ges="s" doxml.id="d28e106" dur="8" oct="4" pname="f" tstamp="1" xml:id="note_3462a"/>
    <note accid.ges="s" doxml.id="d28e108" dur="8" oct="4" pname="f" tstamp="1.5" xml:id="note_3468a"/>
  </reg>
  <orig xml:id="orig_sks_wbs_5wb">
    <note accid.ges="s" doxml.id="d28e106" dur="8" oct="4" pname="f" tstamp="1" xml:id="note_3462b"/>
    <note accid.ges="s" doxml.id="d28e108" dur="8" oct="4" pname="f" tstamp="1.5" xml:id="note_3468b"/>
  </orig>
</choice>

(note the adding of reg@type)

corr-sic

<choice xml:id="choice_aks_1cs_5wb">
  <corr resp="#DME-editors"  xml:id="corr_lxt_1cs_5wb">
    <note accid.ges="s" doxml.id="d28e106" dur="8" oct="4" pname="f" tstamp="1" xml:id="note_3462a"/>
    <note accid.ges="s" doxml.id="d28e108" dur="8" oct="4" pname="f" tstamp="1.5" xml:id="note_3468a"/>
  </corr>
  <sic xml:id="sic_uxt_1cs_5wb">
    <note accid.ges="s" doxml.id="d28e106" dur="8" oct="4" pname="f" tstamp="1" xml:id="note_3462b"/>
    <note accid.ges="s" doxml.id="d28e108" dur="8" oct="4" pname="f" tstamp="1.5" xml:id="note_3468b"/>
  </sic>
</choice>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants