Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
ddrury committed Dec 7, 2021
1 parent cc4c83a commit 269bc4c
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 20 deletions.
4 changes: 3 additions & 1 deletion app/Elements/AbstractElement.php
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,9 @@ protected function valueFormatted(string $value, Tree $tree): string
$format = $tree->getPreference('FORMAT_TEXT');

if ($format === 'markdown') {
$html = Registry::markdownFactory()->markdown($tree)->convertToHtml($canonical);
// Two trailing spaces create a line-break in markdown
$html = strtr($canonical, ["\n" => " \n"]);
$html = Registry::markdownFactory()->markdown($tree)->convertToHtml($html);

return '<div class="markdown" dir="auto">' . $html . '</div>';
}
Expand Down
6 changes: 4 additions & 2 deletions app/Functions/FunctionsPrint.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
use Fisharebest\Webtrees\Age;
use Fisharebest\Webtrees\Auth;
use Fisharebest\Webtrees\Date;
use Fisharebest\Webtrees\Elements\SubmitterText;
use Fisharebest\Webtrees\Fact;
use Fisharebest\Webtrees\Family;
use Fisharebest\Webtrees\Gedcom;
Expand Down Expand Up @@ -75,6 +76,7 @@ class FunctionsPrint
private static function printNoteRecord(Tree $tree, string $text, int $nlevel, string $nrec): string
{
$text .= Functions::getCont($nlevel, $nrec);
$element = new SubmitterText('');

if (preg_match('/^0 @(' . Gedcom::REGEX_XREF . ')@ NOTE/', $nrec, $match)) {
// Shared note.
Expand All @@ -83,14 +85,14 @@ private static function printNoteRecord(Tree $tree, string $text, int $nlevel, s
assert($note instanceof Note);

$label = I18N::translate('Shared note');
$html = Registry::markdownFactory()->markdown($tree)->convertToHtml($note->getNote());
$html = $element->value($note->getNote(), $tree);
$first_line = '<a href="' . e($note->url()) . '">' . $note->fullName() . '</a>';

$one_line_only = strip_tags($note->fullName()) === strip_tags($note->getNote());
} else {
// Inline note.
$label = I18N::translate('Note');
$html = Registry::markdownFactory()->markdown($tree)->convertToHtml($text);
$html = $element->value($text, $tree);

[$first_line] = explode("\n", strip_tags($html));
// Use same logic as note objects
Expand Down
2 changes: 1 addition & 1 deletion app/Http/RequestHandlers/ManageMediaData.php
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ public function handle(ServerRequestInterface $request): ResponseInterface
*/
private function mediaObjectInfo(Media $media): string
{
$html = '<b><a href="' . e($media->url()) . '">' . $media->fullName() . '</a></b>' . '<br><i>' . e($media->getNote()) . '</i></br><br>';
$html = '<b><a href="' . e($media->url()) . '">' . $media->fullName() . '</a></b>' . $media->getNote();

$linked = [];
foreach ($media->linkedIndividuals('OBJE') as $link) {
Expand Down
2 changes: 2 additions & 0 deletions app/Http/RequestHandlers/NotePage.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

use Fig\Http\Message\StatusCodeInterface;
use Fisharebest\Webtrees\Auth;
use Fisharebest\Webtrees\Elements\SubmitterText;
use Fisharebest\Webtrees\Http\ViewResponseTrait;
use Fisharebest\Webtrees\Registry;
use Fisharebest\Webtrees\Services\ClipboardService;
Expand Down Expand Up @@ -86,6 +87,7 @@ public function handle(ServerRequestInterface $request): ResponseInterface
'record' => $record,
'title' => $record->fullName(),
'tree' => $tree,
'element' => new SubmitterText(''),
]);
}
}
6 changes: 4 additions & 2 deletions app/Media.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

namespace Fisharebest\Webtrees;

use Fisharebest\Webtrees\Elements\SubmitterText;
use Fisharebest\Webtrees\Functions\FunctionsPrintFacts;
use Fisharebest\Webtrees\Http\RequestHandlers\MediaPage;
use Illuminate\Database\Capsule\Manager as DB;
Expand Down Expand Up @@ -93,16 +94,17 @@ public function firstImageFile(): ?MediaFile
public function getNote(): string
{
$fact = $this->facts(['NOTE'])->first();
$element = new SubmitterText('');

if ($fact instanceof Fact) {
// Link to note object
$note = $fact->target();
if ($note instanceof Note) {
return $note->getNote();
return $element->value($note->getnote(), $this->tree);
}

// Inline note
return $fact->value();
return $element->value($fact->value(), $this->tree);
}

return '';
Expand Down
6 changes: 2 additions & 4 deletions app/Module/CensusAssistantModule.php
Original file line number Diff line number Diff line change
Expand Up @@ -178,13 +178,11 @@ private function createNoteText(CensusInterface $census, string $ca_title, strin
$text = $ca_title;

if ($ca_citation !== '') {
// Two trailing spaces create a line-break in markdown
$text .= " \n" . $ca_citation;
$text .= "\n" . $ca_citation;
}

if ($ca_place !== '') {
// Two trailing spaces create a line-break in markdown
$text .= " \n" . $ca_place;
$text .= "\n" . $ca_place;
}

$text .= "\n\n|";
Expand Down
10 changes: 1 addition & 9 deletions resources/views/note-page-details.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,7 @@ use Illuminate\Support\Collection;
<?php endif ?>
</th>
<td>
<?php if ($record->tree()->getPreference('FORMAT_TEXT') === 'markdown') : ?>
<div class="markdown" dir="auto">
<?= Registry::markdownFactory()->markdown($record->tree())->convertToHtml($record->getNote()) ?>
</div>
<?php else : ?>
<div class="markdown" dir="auto" style="white-space: pre-wrap;">
<?= Registry::markdownFactory()->autolink($record->tree())->convertToHtml($record->getNote()) ?>
</div>
<?php endif ?>
<?= $element->value($record->getNote(), $record->tree()) ?>
</td>
</tr>

Expand Down
2 changes: 1 addition & 1 deletion resources/views/note-page.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ use Illuminate\Support\Collection;

<div class="wt-page-content">
<?= view('record-page-links', [
'details' => view('note-page-details', ['clipboard_facts' => $clipboard_facts, 'record' => $record]),
'details' => view('note-page-details', ['clipboard_facts' => $clipboard_facts, 'record' => $record, 'element' => $element]),
'linked_families' => $linked_families,
'linked_individuals' => $linked_individuals,
'linked_media_objects' => $linked_media_objects,
Expand Down

0 comments on commit 269bc4c

Please sign in to comment.