better examples

This commit is contained in:
lingdocs 2022-05-09 17:23:55 -05:00
parent 3255b15961
commit 97364b284f
4 changed files with 14 additions and 14 deletions

View File

@ -1,6 +1,6 @@
{ {
"name": "@lingdocs/pashto-inflector", "name": "@lingdocs/pashto-inflector",
"version": "2.5.0", "version": "2.5.1",
"author": "lingdocs.com", "author": "lingdocs.com",
"description": "A Pashto inflection and verb conjugation engine, inculding React components for displaying Pashto text, inflections, and conjugations", "description": "A Pashto inflection and verb conjugation engine, inculding React components for displaying Pashto text, inflections, and conjugations",
"homepage": "https://verbs.lingdocs.com", "homepage": "https://verbs.lingdocs.com",

View File

@ -23,25 +23,22 @@ function EnglishContent({ children }: { children: (string | JSX.Element)[] | (st
</div>; </div>;
} }
function Examples({ function Examples(props: ({
children, ex: T.PsJSX | T.PsJSX[] | PsStringWSub | PsStringWSub[],
ex, } | {
opts, children: T.PsJSX | T.PsJSX[] | PsStringWSub | PsStringWSub[],
lineHeight, }) & {
}: {
ex?: PsStringWSub | PsStringWSub[] | T.PsJSX | T.PsJSX[],
children: PsStringWSub | PsStringWSub[],
opts: T.TextOptions, opts: T.TextOptions,
lineHeight?: 0 | 1 | 2 | 3 | 4, lineHeight?: 0 | 1 | 2 | 3 | 4,
}) { }) {
const examples = children || ex; const examples = "children" in props ? props.children : props.ex;
const Example = ({ children: text }: { children: PsStringWSub }) => ( const Example = ({ children: text }: { children: PsStringWSub }) => (
<div className={lineHeight !== undefined ? `mb-${lineHeight}` : `mt-1 mb-3`}> <div className={props.lineHeight !== undefined ? `mb-${props.lineHeight}` : `mt-1 mb-3`}>
<div> <div>
<Pashto opts={opts}>{text}</Pashto> <Pashto opts={props.opts}>{text}</Pashto>
</div> </div>
<div> <div>
<Phonetics opts={opts}>{text}</Phonetics> <Phonetics opts={props.opts}>{text}</Phonetics>
</div> </div>
{text.e && <EnglishContent> {text.e && <EnglishContent>
{text.e} {text.e}
@ -53,9 +50,11 @@ function Examples({
); );
return Array.isArray(examples) ? return Array.isArray(examples) ?
<div> <div>
{/* @ts-ignore */}
{examples.map((example, i) => <Example key={i}>{example}</Example>)} {examples.map((example, i) => <Example key={i}>{example}</Example>)}
</div> </div>
: :
// @ts-ignore
<Example>{examples}</Example>; <Example>{examples}</Example>;
} }

View File

@ -19,7 +19,7 @@ import * as T from "../types";
* @param dealWithString * @param dealWithString
* @returns * @returns
*/ */
export function psJSXMap(ps: T.PsJSX, target: "p" | "f", dealWithString: (ps: T.PsString) => string): JSX.Element { export function psJSXMap(ps: T.PsJSX, target: "p" | "f", dealWithString: (ps: T.PsString) => string | JSX.Element): JSX.Element {
const base = ps[target]; const base = ps[target];
const sec = ps[target === "p" ? "f" : "p"]; const sec = ps[target === "p" ? "f" : "p"];
try { try {

View File

@ -93,6 +93,7 @@ const equativeBuilders: Record<T.EquativeTense, (p: T.Person, n: boolean) => str
return [ return [
`$SUBJ ${getEnglishConj(p, g.englishEquative.present)}${not(n)} $PRED`, `$SUBJ ${getEnglishConj(p, g.englishEquative.present)}${not(n)} $PRED`,
`$SUBJ tend${isThirdPersonSing(p) ? "s" : ""}${not(n)} to be $PRED`, `$SUBJ tend${isThirdPersonSing(p) ? "s" : ""}${not(n)} to be $PRED`,
`$SUBJ ${n ? "don't " : ""}be $PRED`,
]; ];
}, },
subjunctive: (p, n) => { subjunctive: (p, n) => {