R 함수로 생성된 HTML 삽입
P粉513316221
P粉513316221 2024-04-01 20:51:51
0
1
371

동적으로 HTML을 빌드하고 해당 HTML을 렌더링하고 싶습니다. 4분할에. 실제 애플리케이션에는 iFrame 삽입이 포함됩니다. 하지만 간단하게 유지하기 위해 <img> 태그를 만들어 보겠습니다.

내 .qmd 코드는 다음과 같습니다.

으아아아

렌더링되고 함수가 분명히 호출됩니다. 하지만 이미지 대신 HTML 코드가 표시됩니다.

간단한 건 알지만 찾을 수가 없어요. 매우 감사합니다!

P粉513316221
P粉513316221

모든 응답(1)
P粉883973481

주의해야 할 두 가지 사항이 있습니다:

  • 우선, Quarto는 기본적으로 모든 코드 블록 출력을

     tag. To get the output asis you need to use the chunk option results: asis.

  • Secondly, sprintf (or even print) returns output enclosed within quotes. So after using results: asis, you would get the html tags but would also get the quotes. So you need to wrap the sprintf with cat to get intended results.

---
format: html
---

```{r}
#| echo: false
imageLink  %s", iUrl, iText))
}
```

```{r}
#| echo: false
#| results: asis
imageLink("https://www.united.com/8cd8323f017505df6908afc0b72b4925.svg", "united logo")
```

and now, here's what it's supposed to look like:

 united logo
로 래핑합니다.
최신 다운로드
더>
웹 효과
웹사이트 소스 코드
웹사이트 자료
프론트엔드 템플릿
회사 소개 부인 성명 Sitemap
PHP 중국어 웹사이트:공공복지 온라인 PHP 교육,PHP 학습자의 빠른 성장을 도와주세요!