Skip to content

Issue #1125: Allow markdown formatting in "Description"#56

Open
kuchtiak-ufal wants to merge 16 commits intoclarin-v7from
issue_#1125
Open

Issue #1125: Allow markdown formatting in "Description"#56
kuchtiak-ufal wants to merge 16 commits intoclarin-v7from
issue_#1125

Conversation

@kuchtiak-ufal
Copy link

Now,

Based on the

MarkdownConfig = {
    enabled: false,
    mathjax: false,
  };

definition user can use the https://commonmark.org/ or for https://www.mathjax.org/ formatting in the description property.

Example:
Description Metadata text:

## Math Expression
___
* enabled: true
* mathjax: true
___
The [Demo](https://www.mathjax.org/#demo)

When $a \ne 0$, there are two solutions to $ax^2 + bx + c = 0$ and they are
$$x = {-b \pm \sqrt{b^2-4ac} \over 2a}.$$

Result:
Screenshot 2025-10-13 at 17 27 28

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR implements markdown formatting support for description metadata fields in DSpace items. Users can now enable markdown and MathJax formatting in description fields through configuration.

Key changes:

  • Added configuration injection to access markdown settings
  • Implemented conditional rendering between plain text and markdown formats
  • Fixed trailing comma syntax error in configuration

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
src/config/default-app-config.ts Fixed trailing comma syntax error in markdown configuration
src/app/item-page/simple/field-components/clarin-description-item-field/clarin-description-item-field.component.ts Added configuration injection and conditional logic for markdown rendering
src/app/item-page/simple/field-components/clarin-description-item-field/clarin-description-item-field.component.html Added conditional rendering with markdown pipe when enabled

kuchtiak-ufal and others added 11 commits October 14, 2025 12:01
…e markdown text, in the Home page - Add <Markdown formatted text> toggle button to render markdown formatted text
Update the SubmissionSectionCcLicensesComponent spec to wait before asserting the getCcLicenseLink call. The test now uses a setTimeout(350) and the Jasmine done callback, calling fixture.detectChanges inside the timeout before verifying submissionCcLicenseUrlDataService.getCcLicenseLink was invoked with the expected Map. This change prevents timing-related flakiness by allowing async updates to complete before the assertion.
Add markdown preview toggle for description fields
Detect nested markdown toggle and add test
fix(markdown-preview): cache toggle visibility and normalize usemarkdown truthy value handling
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 27 out of 27 changed files in this pull request and generated 7 comments.

Comments suppressed due to low confidence (1)

src/app/submission/sections/cc-license/submission-section-cc-licenses.component.spec.ts:267

  • These specs now use real timers (setTimeout + done) to wait for debounced behavior. This makes the suite slower and more flaky compared to the existing fakeAsync/tick pattern already used in this file. Prefer wrapping these tests in fakeAsync and advancing time with tick(...) (or flushing the debounce scheduler) instead of using real timeouts.
      it('should call the submission cc licenses data service getCcLicenseLink method', (done) => {
        setTimeout(() => {
          fixture.detectChanges();
          expect(submissionCcLicenseUrlDataService.getCcLicenseLink).toHaveBeenCalledWith(
            ccLicence,
            new Map([
              [ccLicence.fields[0], ccLicence.fields[0].enums[1]],
              [ccLicence.fields[1], ccLicence.fields[1].enums[0]],
            ])
          );
          done();
        }, 350);
      });

      it('should display a cc license link', (done) => {
        // Wait for the debounced observable to emit
        setTimeout(() => {
          fixture.detectChanges();
          const linkElement = de.query(By.css('.license-link'));
          expect(linkElement).toBeTruthy();
          done();
        }, 350); // Wait longer than the 300ms debounce
      });

Comment on lines +175 to +177
markdown:
enabled: true
mathjax: true
Copy link

Copilot AI Mar 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This update enables markdown + MathJax by default in the main runtime config. That’s a significant behavior and performance change (MathJax rendering can be expensive, and enabling markdown affects how user-provided metadata is displayed). Please confirm this is intentional for all deployments; otherwise keep defaults disabled and document/enable per environment as needed.

Suggested change
markdown:
enabled: true
mathjax: true
# Markdown rendering configuration.
# Disabled by default for performance and to avoid changing how user-provided metadata is displayed.
# Enable these options in an environment-specific config only if your deployment requires them.
markdown:
enabled: false
mathjax: false

Copilot uses AI. Check for mistakes.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kosarko
seems like that’s a product decision

Conditionally render markdown description panel
Disable MathJax for markdown
Clarify default allowlisted markdown fields
Move markdown description metadata allow list into a shared constant and replace inline copies across components. Improve markdown preview toggle behavior and accessibility: add aria-label/aria-pressed attributes in the template, add shouldBindMarkdownToggleVisibility() and clearMarkdownToggleVisibilityBinding() to avoid binding/ subscriptions when markdown is disabled, field is not a textarea, or field is readOnly, and ensure proper cleanup. Update unit tests to handle global appConfig markdown state and add cases for hiding the toggle when global markdown is disabled or when not editing.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants